@@ -29,6 +29,7 @@ import (
29
29
"os"
30
30
"os/exec"
31
31
"path/filepath"
32
+ "regexp"
32
33
"strings"
33
34
"testing"
34
35
"time"
@@ -87,6 +88,7 @@ func TestFunctional(t *testing.T) {
87
88
{"MountCmd" , validateMountCmd },
88
89
{"ProfileCmd" , validateProfileCmd },
89
90
{"ServicesCmd" , validateServicesCmd },
91
+ {"AddonsCmd" , validateAddonsCmd },
90
92
{"PersistentVolumeClaim" , validatePersistentVolumeClaim },
91
93
{"TunnelCmd" , validateTunnelCmd },
92
94
{"SSHCmd" , validateSSHCmd },
@@ -314,6 +316,52 @@ func validateServicesCmd(ctx context.Context, t *testing.T, profile string) {
314
316
}
315
317
}
316
318
319
+ // validateAddonsCmd asserts basic "addon" command functionality
320
+ func validateAddonsCmd (ctx context.Context , t * testing.T , profile string ) {
321
+
322
+ // Default output
323
+ rr , err := Run (t , exec .CommandContext (ctx , Target (), "-p" , profile , "addons" , "list" ))
324
+ if err != nil {
325
+ t .Errorf ("%s failed: %v" , rr .Args , err )
326
+ }
327
+ listLines := strings .Split (strings .TrimSpace (rr .Stdout .String ()), "\n " )
328
+ r := regexp .MustCompile (`-\s[a-z|-]+:\s(enabled|disabled)` )
329
+ for _ , line := range listLines {
330
+ match := r .MatchString (line )
331
+ if ! match {
332
+ t .Errorf ("Plugin output did not match expected format. Got: %s" , line )
333
+ }
334
+ }
335
+
336
+ // Custom format
337
+ rr , err = Run (t , exec .CommandContext (ctx , Target (), "-p" , profile , "addons" , "list" , "--format" , `"{{.AddonName}}":"{{.AddonStatus}}"` ))
338
+ if err != nil {
339
+ t .Errorf ("%s failed: %v" , rr .Args , err )
340
+ }
341
+ listLines = strings .Split (strings .TrimSpace (rr .Stdout .String ()), "\n " )
342
+ r = regexp .MustCompile (`"[a-z|-]+":"(enabled|disabled)"` )
343
+ for _ , line := range listLines {
344
+ match := r .MatchString (line )
345
+ if ! match {
346
+ t .Errorf ("Plugin output did not match expected custom format. Got: %s" , line )
347
+ }
348
+ }
349
+
350
+ // Custom format shorthand
351
+ rr , err = Run (t , exec .CommandContext (ctx , Target (), "-p" , profile , "addons" , "list" , "-f" , `"{{.AddonName}}":"{{.AddonStatus}}"` ))
352
+ if err != nil {
353
+ t .Errorf ("%s failed: %v" , rr .Args , err )
354
+ }
355
+ listLines = strings .Split (strings .TrimSpace (rr .Stdout .String ()), "\n " )
356
+ r = regexp .MustCompile (`"[a-z|-]+":"(enabled|disabled)"` )
357
+ for _ , line := range listLines {
358
+ match := r .MatchString (line )
359
+ if ! match {
360
+ t .Errorf ("Plugin output did not match expected custom format. Got: %s" , line )
361
+ }
362
+ }
363
+ }
364
+
317
365
// validateSSHCmd asserts basic "ssh" command functionality
318
366
func validateSSHCmd (ctx context.Context , t * testing.T , profile string ) {
319
367
if NoneDriver () {
0 commit comments