MCPcopy Create free account
hub / github.com/exercism/cli / TestConfigureToken

Function TestConfigureToken

cmd/configure_test.go:81–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestConfigureToken(t *testing.T) {
82 co := newCapturedOutput()
83 co.override()
84 defer co.reset()
85
86 testCases := []struct {
87 desc string
88 configured string
89 args []string
90 expected string
91 message string
92 err bool
93 }{
94 {
95 desc: "It doesn't lose a configured value",
96 configured: "existing-token",
97 args: []string{"--no-verify"},
98 expected: "existing-token",
99 },
100 {
101 desc: "It writes a token when passed as a flag",
102 configured: "",
103 args: []string{"--no-verify", "--token", "a-token"},
104 expected: "a-token",
105 },
106 {
107 desc: "It overwrites the token",
108 configured: "old-token",
109 args: []string{"--no-verify", "--token", "replacement-token"},
110 expected: "replacement-token",
111 },
112 {
113 desc: "It complains when token is neither configured nor passed",
114 configured: "",
115 args: []string{"--no-verify"},
116 expected: "",
117 err: true,
118 message: "no token configured",
119 },
120 {
121 desc: "It validates the existing token if we're not skipping validations",
122 configured: "configured-token",
123 args: []string{},
124 expected: "configured-token",
125 err: true,
126 message: "token.*invalid",
127 },
128 {
129 desc: "It validates the replacement token if we're not skipping validations",
130 configured: "",
131 args: []string{"--token", "invalid-token"},
132 expected: "",
133 err: true,
134 message: "token.*invalid",
135 },
136 }
137
138 endpoint := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 6

newCapturedOutputFunction · 0.85
setupConfigureFlagsFunction · 0.85
runConfigureFunction · 0.85
overrideMethod · 0.80
resetMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected