Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Griffin <prakritimandal611@gmail.com>
  • Loading branch information
prakrit55 committed May 30, 2024
1 parent 6d2a1af commit dfb4a79
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/safeexpvar/cacheexpvar_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package safeexpvar

import (
"expvar"
"testing"

"github.com/stretchr/testify/assert"
)

func TestSetExpvarInt(t *testing.T) {
// Test with a new variable
name := "metrics-test-1"
value := int64(42)

SetExpvarInt(name, value)

// Retrieve the variable and check its value
v := expvar.Get(name)
assert.NotNil(t, v, "expected variable %s to be created", name)
expInt, ok := v.(*expvar.Int)
assert.True(t, ok, "expected variable %s to be of type *expvar.Int", name)
assert.Equal(t, value, expInt.Value(), "expected variable %s value to be %d", name, value)
}
File renamed without changes.

0 comments on commit dfb4a79

Please sign in to comment.