github.com/JarrahG/buffalocli@v0.0.0-20230801092127-b85bfd5d395a/internal/cmd/test/test_test.go (about)

     1  package test
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func Test_CutArg(t *testing.T) {
     9  	tests := []struct {
    10  		arg      string
    11  		args     []string
    12  		expected []string
    13  	}{
    14  		{"b", []string{"a", "b", "c"}, []string{"a", "c"}},
    15  		{"--is-not-in-args", []string{"a", "b", "c"}, []string{"a", "b", "c"}},
    16  		{"--foo", []string{"--foo", "--bar", "--baz"}, []string{"--bar", "--baz"}},
    17  		{"--force-migrations", []string{"./actions/", "--force-migrations"}, []string{"./actions/"}},
    18  		{"--force-migrations", []string{"./actions/", "--force-migrations", "-m", "Test_HomeHandler"}, []string{"./actions/", "-m", "Test_HomeHandler"}},
    19  	}
    20  
    21  	for _, tt := range tests {
    22  		result := cutArg(tt.arg, tt.args)
    23  		if !reflect.DeepEqual(result, tt.expected) {
    24  			t.Errorf("got %s, want %s when cutting %s from %s", result, tt.expected, tt.arg, tt.args)
    25  		}
    26  	}
    27  }