github.com/DelineaXPM/dsv-cli@v1.40.6/tests/e2e/cmd_pool_test.go (about) 1 //go:build endtoend 2 // +build endtoend 3 4 package e2e 5 6 import ( 7 "fmt" 8 "runtime" 9 "testing" 10 ) 11 12 func TestPool(t *testing.T) { 13 e := newEnv() 14 15 poolName1 := makePoolName() 16 poolName2 := makePoolName() 17 18 output := runWithProfile(t, "pool") 19 requireLine(t, output, "Work with engine pools") 20 21 output = runWithProfile(t, "pool --help") 22 requireLine(t, output, "Work with engine pools") 23 24 output = runWithProfile(t, "pool create --help") 25 requireContains(t, output, "Create a new empty pool of engines") 26 27 output = runWithProfile(t, fmt.Sprintf("pool create --name=%s", poolName1)) 28 requireContains(t, output, fmt.Sprintf(`"createdBy": "users:%s",`, e.username)) 29 requireContains(t, output, fmt.Sprintf(`"name": "%s"`, poolName1)) 30 31 output = runWithProfile(t, "pool read --help") 32 requireContains(t, output, "Get information on an existing pool of engines") 33 34 output = runWithProfile(t, "pool read") 35 requireContains(t, output, "error: must specify name") 36 37 output = runWithProfile(t, fmt.Sprintf("pool read --name=%s", poolName1)) 38 requireContains(t, output, fmt.Sprintf(`"createdBy": "users:%s",`, e.username)) 39 requireContains(t, output, fmt.Sprintf(`"name": "%s"`, poolName1)) 40 41 output = runWithProfile(t, fmt.Sprintf("pool read %s", poolName1)) 42 requireContains(t, output, fmt.Sprintf(`"createdBy": "users:%s",`, e.username)) 43 requireContains(t, output, fmt.Sprintf(`"name": "%s"`, poolName1)) 44 45 output = runWithProfile(t, fmt.Sprintf("pool %s", poolName1)) 46 requireContains(t, output, fmt.Sprintf(`"createdBy": "users:%s",`, e.username)) 47 requireContains(t, output, fmt.Sprintf(`"name": "%s"`, poolName1)) 48 49 output = runWithProfile(t, fmt.Sprintf("pool create --name=%s", poolName2)) 50 requireContains(t, output, fmt.Sprintf(`"createdBy": "users:%s",`, e.username)) 51 requireContains(t, output, fmt.Sprintf(`"name": "%s"`, poolName2)) 52 53 output = runWithProfile(t, "pool list --help") 54 requireContains(t, output, "List the names of all existing pools") 55 56 output = runWithProfile(t, "pool list") 57 requireContains(t, output, `"pools": [`) 58 requireContains(t, output, fmt.Sprintf(`"name": "%s"`, poolName1)) 59 requireContains(t, output, fmt.Sprintf(`"name": "%s"`, poolName2)) 60 61 output = runWithProfile(t, "pool list --limit 1") 62 requireContains(t, output, `"length": 1`) 63 requireContains(t, output, `"limit": 1`) 64 requireContains(t, output, `"pools": [`) 65 66 output = runWithProfile(t, "pool delete --help") 67 requireContains(t, output, "Delete an existing pool of engines") 68 69 output = runWithProfile(t, "pool delete") 70 requireContains(t, output, "error: must specify name") 71 72 output = runWithProfile(t, fmt.Sprintf("pool delete --name=%s", poolName1)) 73 if output != "" { 74 t.Fatalf("Unexpected output: \n%s\n", output) 75 } 76 output = runWithProfile(t, fmt.Sprintf("pool delete --name=%s", poolName2)) 77 if output != "" { 78 t.Fatalf("Unexpected output: \n%s\n", output) 79 } 80 output = runWithProfile(t, fmt.Sprintf("pool delete %s", poolName1)) 81 requireContains(t, output, `"message": "unable to find item with specified identifier"`) 82 } 83 84 func TestPoolInteractiveCreate(t *testing.T) { 85 if runtime.GOOS == "windows" { 86 t.Skip("Sorry, interactive End-to-End tests cannot be executed on Windows.") 87 } 88 e := newEnv() 89 90 poolName := makePoolName() 91 92 cmd := []string{ 93 "pool", "create", 94 "--auth-type=password", 95 fmt.Sprintf("--auth-username=%s", e.username), 96 fmt.Sprintf("--auth-password=%s", e.password), 97 fmt.Sprintf("--tenant=%s", e.tenant), 98 fmt.Sprintf("--domain=%s", e.domain), 99 } 100 101 runFlow(t, cmd, func(c console) { 102 c.ExpectString("Pool name") 103 c.SendLine(poolName) 104 c.ExpectEOF() 105 }) 106 output := runWithProfile(t, fmt.Sprintf("pool delete --name=%s", poolName)) 107 if output != "" { 108 t.Fatalf("Unexpected output: \n%s\n", output) 109 } 110 }