github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/expressions/globbing_test.go (about)

     1  package expressions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/test/count"
     7  	"github.com/lmorg/murex/utils/json"
     8  	"github.com/lmorg/murex/utils/readline"
     9  )
    10  
    11  func TestAutoGlobPromptHintText(t *testing.T) {
    12  	rl := readline.NewInstance()
    13  
    14  	tests := []struct {
    15  		Match []string
    16  		Hint  string
    17  	}{
    18  		{
    19  			Match: []string{},
    20  			Hint:  warningNoGlobMatch,
    21  		},
    22  		{
    23  			Match: []string{"foo", "bar"},
    24  			Hint:  globExpandsTo+"foo, bar",
    25  		},
    26  		{
    27  			Match: []string{"foo bar"},
    28  			Hint:  globExpandsTo+`foo\ bar`,
    29  		},
    30  	}
    31  
    32  	count.Tests(t, len(tests))
    33  
    34  	for i, test := range tests {
    35  		actual := string(autoGlobPromptHintText(rl, test.Match))
    36  
    37  		if test.Hint != actual {
    38  			t.Errorf("HintText doesn't match expected in test %d", i)
    39  			t.Logf("  Match:     %s", json.LazyLogging(test.Match))
    40  			t.Logf("  Expected: '%s'", test.Hint)
    41  			t.Logf("  Actual:   '%s'", actual)
    42  		}
    43  	}
    44  
    45  }
    46