Files
fx-serverless/context/context_test.go
Minghe c0009b1b64 request a port when not port given (#379)
* request a port when not port given
* make context an interface, for easy testing (#380)
2019-12-03 15:14:13 +08:00

30 lines
492 B
Go

package context
import (
"testing"
"github.com/urfave/cli"
)
func TestContext(t *testing.T) {
ctx := NewContext()
cli := cli.NewContext(nil, nil, nil)
ctx.WithCliContext(cli)
c := ctx.GetCliContext()
if c != cli {
t.Fatalf("should get %v but got %v", cli, c)
}
key := "k_1"
value := "hello"
ctx.Set(key, "hello")
v := ctx.Get(key).(string)
if v != value {
t.Fatalf("should get %v but %v", value, v)
}
if ctx.GetContext() == nil {
t.Fatalf("should get context")
}
}