INNER CODE UNIT · Go

TestLoadWithValidConfig

rameshsunkara/go-rest-api-example · internal/config/config_test.go:11

func TestLoadWithValidConfig(t *testing.T) {
	// Set required environment variables
	t.Setenv("dbHosts", "localhost:27017")
	t.Setenv("DBCredentialsSideCar", "/path/to/credentials")

	cfg, err := config.Load()

	require.NoError(t, err)
	assert.NotNil(t, cfg)
	assert.Equal(t, "localhost:27017", cfg.DBHosts)
	assert.Equal(t, "/path/to/credentials", cfg.DBCredentialsSideCar)
}

func TestLoadMissingRequiredConfig(t *testing.T) {
	// Clear environment variables
	t.Setenv("dbHosts", "")
	t.Setenv("DBCredentialsSideCar", "")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…