diff options
author | Manuel Palenzuela Merino <manuel.palenzuela@datadoghq.com> | 2024-12-05 11:07:35 +0100 |
---|---|---|
committer | Manuel Palenzuela Merino <manuel.palenzuela@datadoghq.com> | 2024-12-05 11:08:17 +0100 |
commit | ee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d (patch) | |
tree | 8aeaa3b76be6cdcf326acf3627b3d283a8b2c372 /main/civisibility/utils/names_test.go | |
parent | Update README.md (diff) | |
download | test-repo-ee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d.tar.gz test-repo-ee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d.tar.bz2 test-repo-ee3c0aa3d71a857ae7fb60f1b98cf129ee6ad71d.zip |
Add tests
Diffstat (limited to 'main/civisibility/utils/names_test.go')
-rw-r--r-- | main/civisibility/utils/names_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/main/civisibility/utils/names_test.go b/main/civisibility/utils/names_test.go new file mode 100644 index 0000000..019aa02 --- /dev/null +++ b/main/civisibility/utils/names_test.go @@ -0,0 +1,39 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2024 Datadog, Inc. + +package utils + +import ( + "runtime" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetModuleAndSuiteName(t *testing.T) { + pc, _, _, _ := runtime.Caller(0) // Get the program counter of this function + _, suite := GetModuleAndSuiteName(pc) + // expectedModule := "gopkg.in/DataDog/dd-trace-go.v1/internal/civisibility/utils" + expectedSuite := "names_test.go" + + // assert.True(t, strings.HasPrefix(module, expectedModule)) + assert.Equal(t, expectedSuite, suite) +} + +func TestGetStacktrace(t *testing.T) { + stacktrace := GetStacktrace(0) + assert.Contains(t, stacktrace, "names_test.go") // Ensure that the current test file is part of the stack trace + assert.Contains(t, stacktrace, "TestGetStacktrace") // Ensure that the current test function is part of the stack trace +} + +func TestGetStacktraceWithSkip(t *testing.T) { + stacktrace := getStacktraceHelper() + assert.Contains(t, stacktrace, "names_test.go") + assert.NotContains(t, stacktrace, "getStacktraceHelper") // Ensure the helper function is skipped +} + +func getStacktraceHelper() string { + return GetStacktrace(1) // Skip this helper function frame +} |