github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/cli/lscolors/lscolors_test.go (about) 1 package lscolors 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/markusbkk/elvish/pkg/testutil" 8 ) 9 10 func TestLsColors(t *testing.T) { 11 testutil.InTempDir(t) 12 SetTestLsColors(t) 13 14 // Test both feature-based and extension-based coloring. 15 16 colorist := GetColorist() 17 18 os.Mkdir("dir", 0755) 19 create("a.png") 20 21 wantDirStyle := "34" 22 if style := colorist.GetStyle("dir"); style != wantDirStyle { 23 t.Errorf("Got dir style %q, want %q", style, wantDirStyle) 24 } 25 wantPngStyle := "31" 26 if style := colorist.GetStyle("a.png"); style != wantPngStyle { 27 t.Errorf("Got dir style %q, want %q", style, wantPngStyle) 28 } 29 }