forked from toolshed/abra
		
	Note: the integration tests don't work due to ValidateApp still attempting to validate the host key for the test app which doesn't exist. This will be fixed in a future commit.
		
			
				
	
	
		
			32 lines
		
	
	
		
			914 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			914 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package app
 | 
						|
 | 
						|
import (
 | 
						|
	"strings"
 | 
						|
	"testing"
 | 
						|
)
 | 
						|
 | 
						|
func TestParseCmdArgs(t *testing.T) {
 | 
						|
	tests := []struct {
 | 
						|
		input          []string
 | 
						|
		shouldParse    bool
 | 
						|
		expectedOutput string
 | 
						|
	}{
 | 
						|
		// `--` is not parsed when passed in from the command-line e.g. -- foo bar baz
 | 
						|
		// so we need to eumlate that as missing when testing if bash args are passed in
 | 
						|
		// see https://git.coopcloud.tech/coop-cloud/organising/issues/336 for more
 | 
						|
		{[]string{"foo.com", "app", "test"}, false, ""},
 | 
						|
		{[]string{"foo.com", "app", "test", "foo"}, true, "foo "},
 | 
						|
		{[]string{"foo.com", "app", "test", "foo", "bar", "baz"}, true, "foo bar baz "},
 | 
						|
	}
 | 
						|
 | 
						|
	for _, test := range tests {
 | 
						|
		ok, parsed := parseCmdArgs(test.input, false)
 | 
						|
		if ok != test.shouldParse {
 | 
						|
			t.Fatalf("[%s] should not parse", strings.Join(test.input, " "))
 | 
						|
		}
 | 
						|
		if parsed != test.expectedOutput {
 | 
						|
			t.Fatalf("%s does not match %s", parsed, test.expectedOutput)
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |