github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/tests/auth_test.go (about) 1 package tests 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func TestAuthAll(t *testing.T) { 9 runTests(t, createAuthMonkey(), true) 10 } 11 12 func createAuthMonkey() *testSpider { 13 command := "login" 14 15 testProfileName := "someProfile" 16 basicNew := func(name string) []string { 17 return []string{ 18 command, testProfileName, 19 "-p", Provider, 20 "-t", Token, 21 22 // Disable output color 23 "--color", "never", 24 } 25 } 26 27 tests := []testMonkey{ 28 { 29 name: "Creating new profile", 30 args: basicNew(testProfileName), 31 wantOut: []string{ 32 fmt.Sprintf("Created default profile: %s", testProfileName), 33 }, 34 evaluateSession: expectProfileName(testProfileName), 35 }, 36 { 37 name: "Creating default profile", 38 args: []string{ 39 command, testProfileName + "2", 40 "-p", Provider, 41 "-t", Token, 42 "--new", 43 "--set-default", 44 45 // Disable output color 46 "--color", "never", 47 }, 48 wantOut: []string{ 49 fmt.Sprintf("Created default profile: %s", testProfileName+"2"), 50 }, 51 preRun: [][]string{ 52 basicNew(testProfileName), 53 }, 54 evaluateSession: expectProfileName(testProfileName + "2"), 55 }, 56 { 57 name: "env should export and not set", 58 args: append(basicNew(testProfileName), "--env"), 59 wantOut: []string{ 60 fmt.Sprintf("Created default profile: %s", testProfileName), 61 fmt.Sprintf("export TAUBYTE_PROFILE=%s", testProfileName), 62 }, 63 evaluateSession: expectProfileName(""), 64 }, 65 { 66 name: "should select", 67 args: []string{ 68 command, testProfileName, 69 70 // Disable output color 71 "--color", "never", 72 }, 73 wantOut: []string{ 74 fmt.Sprintf("Selected profile: %s", testProfileName), 75 }, 76 preRun: [][]string{ 77 basicNew(testProfileName), 78 basicNew(testProfileName + "2"), 79 }, 80 evaluateSession: expectProfileName(testProfileName), 81 }, 82 } 83 return &testSpider{"some_project", tests, nil, nil, "login"} 84 }