1
0
mirror of https://github.com/containous/traefik.git synced 2025-01-08 21:17:56 +03:00
traefik/pkg/safe/safe_test.go

31 lines
594 B
Go
Raw Normal View History

package safe
import "testing"
func TestSafe(t *testing.T) {
const ts1 = "test1"
const ts2 = "test2"
2018-10-12 16:40:03 +03:00
s := New(ts1)
2018-10-12 16:40:03 +03:00
result, ok := s.Get().(string)
if !ok {
t.Fatalf("Safe.Get() failed, got type '%T', expected string", s.Get())
}
2018-10-12 16:40:03 +03:00
if result != ts1 {
t.Errorf("Safe.Get() failed, got '%s', expected '%s'", result, ts1)
}
2018-10-12 16:40:03 +03:00
s.Set(ts2)
2018-10-12 16:40:03 +03:00
result, ok = s.Get().(string)
if !ok {
t.Fatalf("Safe.Get() after Safe.Set() failed, got type '%T', expected string", s.Get())
}
2018-10-12 16:40:03 +03:00
if result != ts2 {
t.Errorf("Safe.Get() after Safe.Set() failed, got '%s', expected '%s'", result, ts2)
}
}