@@ -64,8 +64,6 @@ func TestCurrentVersion(t *testing.T) {
6464 }
6565}
6666
67- var ansiRegex = regexp .MustCompile (`\x1b\[[0-9;]*m` )
68-
6967func captureOutput (f func ()) string {
7068 var buf bytes.Buffer
7169 stdout := os .Stdout
@@ -82,6 +80,8 @@ func captureOutput(f func()) string {
8280}
8381
8482func stripANSI (input string ) string {
83+ // Regular expression to match ANSI escape sequences
84+ ansiRegex := regexp .MustCompile (`\x1b\[[0-9;]*m` )
8585 return ansiRegex .ReplaceAllString (input , "" )
8686}
8787
@@ -95,67 +95,70 @@ func TestRunCLI(t *testing.T) {
9595 {
9696 name : "No Arguments" ,
9797 args : []string {},
98- expectedOutput : "╭────────────────────────────────────────────────────────╮\n " +
99- "│Welcome! This tool displays data related to Pokémon! │\n " +
100- "│ │\n " +
101- "│ USAGE: │\n " +
102- "│ poke-cli [flag] │\n " +
103- "│ poke-cli <command> [flag] │\n " +
104- "│ poke-cli <command> <subcommand> [flag] │\n " +
105- "│ │\n " +
106- "│ FLAGS: │\n " +
107- "│ -h, --help Shows the help menu │\n " +
108- "│ -l, --latest Prints the latest version available │\n " +
109- "│ -v, --version Prints the current version │\n " +
110- "│ │\n " +
111- "│ AVAILABLE COMMANDS: │\n " +
112- "│ pokemon Get details of a specific Pokémon │\n " +
113- "│ types Get details of a specific typing │\n " +
114- "╰────────────────────────────────────────────────────────╯\n " ,
98+ expectedOutput : "╭─────────────────────────────────────────────────────────╮\n " +
99+ "│Welcome! This tool displays data related to Pokémon! │\n " +
100+ "│ │\n " +
101+ "│ USAGE: │\n " +
102+ "│ poke-cli [flag] │\n " +
103+ "│ poke-cli <command> [flag] │\n " +
104+ "│ poke-cli <command> <subcommand> [flag] │\n " +
105+ "│ │\n " +
106+ "│ FLAGS: │\n " +
107+ "│ -h, --help Shows the help menu │\n " +
108+ "│ -l, --latest Prints the latest version available │\n " +
109+ "│ -v, --version Prints the current version │\n " +
110+ "│ │\n " +
111+ "│ COMMANDS: │\n " +
112+ "│ natures Get details about Pokémon natures │\n " +
113+ "│ pokemon Get details about a specific Pokémon │\n " +
114+ "│ types Get details about a specific typing │\n " +
115+ "╰─────────────────────────────────────────────────────────╯\n " ,
115116 expectedCode : 0 ,
116117 },
117118 {
118119 name : "Help Flag Short" ,
119120 args : []string {"-h" },
120- expectedOutput : "╭────────────────────────────────────────────────────────╮\n " +
121- "│Welcome! This tool displays data related to Pokémon! │\n " +
122- "│ │\n " +
123- "│ USAGE: │\n " +
124- "│ poke-cli [flag] │\n " +
125- "│ poke-cli <command> [flag] │\n " +
126- "│ poke-cli <command> <subcommand> [flag] │\n " +
127- "│ │\n " +
128- "│ FLAGS: │\n " +
129- "│ -h, --help Shows the help menu │\n " +
130- "│ -l, --latest Prints the latest version available │\n " +
131- "│ -v, --version Prints the current version │\n " +
132- "│ │\n " +
133- "│ AVAILABLE COMMANDS: │\n " +
134- "│ pokemon Get details of a specific Pokémon │\n " +
135- "│ types Get details of a specific typing │\n " +
136- "╰────────────────────────────────────────────────────────╯\n " ,
121+ expectedOutput : "╭─────────────────────────────────────────────────────────╮\n " +
122+ "│Welcome! This tool displays data related to Pokémon! │\n " +
123+ "│ │\n " +
124+ "│ USAGE: │\n " +
125+ "│ poke-cli [flag] │\n " +
126+ "│ poke-cli <command> [flag] │\n " +
127+ "│ poke-cli <command> <subcommand> [flag] │\n " +
128+ "│ │\n " +
129+ "│ FLAGS: │\n " +
130+ "│ -h, --help Shows the help menu │\n " +
131+ "│ -l, --latest Prints the latest version available │\n " +
132+ "│ -v, --version Prints the current version │\n " +
133+ "│ │\n " +
134+ "│ COMMANDS: │\n " +
135+ "│ natures Get details about Pokémon natures │\n " +
136+ "│ pokemon Get details about a specific Pokémon │\n " +
137+ "│ types Get details about a specific typing │\n " +
138+ "╰─────────────────────────────────────────────────────────╯\n " ,
137139 expectedCode : 0 ,
138140 },
139141 {
140142 name : "Help Flag Long" ,
141143 args : []string {"--help" },
142- expectedOutput : "╭────────────────────────────────────────────────────────╮\n " +
143- "│Welcome! This tool displays data related to Pokémon! │\n " +
144- "│ │\n " +
145- "│ USAGE: │\n " +
146- "│ poke-cli [flag] │\n " +
147- "│ poke-cli <command> [flag] │\n " +
148- "│ poke-cli <command> <subcommand> [flag] │\n " +
149- "│ │\n " +
150- "│ FLAGS: │\n " +
151- "│ -h, --help Shows the help menu │\n " +
152- "│ -l, --latest Prints the latest version available │\n " +
153- "│ -v, --version Prints the current version │\n " +
154- "│ │\n " +
155- "│ AVAILABLE COMMANDS: │\n " +
156- "│ pokemon Get details of a specific Pokémon │\n " +
157- "│ types Get details of a specific typing │\n " +
158- "╰────────────────────────────────────────────────────────╯\n " ,
144+ expectedOutput : "╭─────────────────────────────────────────────────────────╮\n " +
145+ "│Welcome! This tool displays data related to Pokémon! │\n " +
146+ "│ │\n " +
147+ "│ USAGE: │\n " +
148+ "│ poke-cli [flag] │\n " +
149+ "│ poke-cli <command> [flag] │\n " +
150+ "│ poke-cli <command> <subcommand> [flag] │\n " +
151+ "│ │\n " +
152+ "│ FLAGS: │\n " +
153+ "│ -h, --help Shows the help menu │\n " +
154+ "│ -l, --latest Prints the latest version available │\n " +
155+ "│ -v, --version Prints the current version │\n " +
156+ "│ │\n " +
157+ "│ COMMANDS: │\n " +
158+ "│ natures Get details about Pokémon natures │\n " +
159+ "│ pokemon Get details about a specific Pokémon │\n " +
160+ "│ types Get details about a specific typing │\n " +
161+ "╰─────────────────────────────────────────────────────────╯\n " ,
159162 expectedCode : 0 ,
160163 },
161164 {
@@ -167,7 +170,7 @@ func TestRunCLI(t *testing.T) {
167170 {
168171 name : "Latest Flag" ,
169172 args : []string {"-l" },
170- expectedOutput : "Latest Docker image version: v0.9.2 \n Latest release tag: v0.9.2 \n " ,
173+ expectedOutput : "Latest Docker image version: v0.9.3 \n Latest release tag: v0.9.3 \n " ,
171174 expectedCode : 0 ,
172175 },
173176 }
0 commit comments