Skip to content

Commit

Permalink
Add test cases for internal utils
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Aug 16, 2024
1 parent b45804a commit e181d48
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions sdk/internal/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package internal

import (
"os"
"testing"

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

func TestGetDefaultString(t *testing.T) {
assert.Equal(t, "default", GetDefaultString("", "default"))
assert.Equal(t, "custom", GetDefaultString("custom", "default"))
assert.Equal(t, "", GetDefaultString("", "", ""))
}

func TestMemoryAndRollback(t *testing.T) {
os.Setenv("test", "old")
rollback := Memory("test")
os.Setenv("test", "new")
rollback()

assert.Equal(t, "old", os.Getenv("test"))
}

0 comments on commit e181d48

Please sign in to comment.