github.com/devcamcar/cli@v0.0.0-20181107134215-706a05759d18/test/cli_config_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 6 "github.com/fnproject/cli/testharness" 7 ) 8 9 func TestContextCrud(t *testing.T) { 10 t.Parallel() 11 h := testharness.Create(t) 12 defer h.Cleanup() 13 14 h.Fn("list", "context").AssertSuccess().AssertStdoutContains("default") 15 h.Fn("create", "context", "--api-url", "alskjalskdjasd/v2", "mycontext").AssertFailed().AssertStderrContains("Invalid Fn API URL: does not contain ://") 16 h.Fn("create", "context", "--api-url", "http://alskjalskdjasd", "mycontext").AssertSuccess() 17 h.Fn("use", "context", "mycontext").AssertSuccess() 18 h.Fn("update", "context", "api-url", "alskjalskdjaff/v2").AssertFailed() 19 h.Fn("update", "context", "api-url").AssertFailed().AssertStderrContains("Please specify a value") 20 h.Fn("update", "context", "api-url", "http://alskjalskdjaf").AssertSuccess() 21 h.Fn("update", "context", "--delete").AssertFailed().AssertStderrContains("Update context files using fn update context requires the missing argument '<key>'") 22 h.Fn("update", "context", "api-u", "--delete").AssertFailed().AssertStderrContains("Context file does not contain key: api-u") 23 h.Fn("update", "context", "api-url", "--delete").AssertSuccess().AssertStdoutContains("Current context deleted api-url") 24 h.Fn("delete", "context", "mycontext").AssertFailed().AssertStderrContains("Cannot delete the current context: mycontext") 25 h.Fn("unset", "context", "mycontext").AssertSuccess() 26 h.Fn("delete", "context", "mycontext").AssertSuccess() 27 }