forked from mtusi2026/mtusi2026lab3
feat(app) lab 3 implemented
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestInstanceIDUsesConfiguredValue(t *testing.T) {
|
||||
t.Setenv("INSTANCE_ID", " api-1 ")
|
||||
|
||||
got, err := instanceID()
|
||||
if err != nil {
|
||||
t.Fatalf("instanceID: %v", err)
|
||||
}
|
||||
if got != "api-1" {
|
||||
t.Fatalf("instanceID = %q, want api-1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstanceIDFallsBackToHostname(t *testing.T) {
|
||||
t.Setenv("INSTANCE_ID", " ")
|
||||
|
||||
got, err := instanceID()
|
||||
if err != nil {
|
||||
t.Fatalf("instanceID: %v", err)
|
||||
}
|
||||
if got == "" {
|
||||
t.Fatal("instanceID returned an empty value")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user