Skip to content

Commit

Permalink
test: Add tests for the GetLocales function
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Dec 23, 2024
1 parent bf0b65a commit 1f0ff8b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cmd/cs_sdk/api/get-locales_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package api

import (
"os"
"testing"

"github.com/Dobefu/csb/cmd/init_env"
"github.com/stretchr/testify/assert"
)

func TestGetLocales(t *testing.T) {
init_env.Main("../../../.env.test")

var locales interface{}

locales = GetLocales()
assert.NotEqual(t, nil, locales)

oldApiKey := os.Getenv("CS_API_KEY")
os.Setenv("CS_API_KEY", "bogus")

locales = GetLocales()
assert.Equal(t, nil, locales)

os.Setenv("CS_API_KEY", oldApiKey)
}

0 comments on commit 1f0ff8b

Please sign in to comment.