github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/pkg/cli/lscolors/lscolors_test.go (about)

     1  package lscolors
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"src.elv.sh/pkg/testutil"
     8  )
     9  
    10  func TestLsColors(t *testing.T) {
    11  	_, cleanup := testutil.InTestDir()
    12  	defer cleanup()
    13  	restoreLsColors := WithTestLsColors()
    14  	defer restoreLsColors()
    15  
    16  	// Test both feature-based and extension-based coloring.
    17  
    18  	colorist := GetColorist()
    19  
    20  	os.Mkdir("dir", 0755)
    21  	create("a.png", 0644)
    22  
    23  	wantDirStyle := "34"
    24  	if style := colorist.GetStyle("dir"); style != wantDirStyle {
    25  		t.Errorf("Got dir style %q, want %q", style, wantDirStyle)
    26  	}
    27  	wantPngStyle := "31"
    28  	if style := colorist.GetStyle("a.png"); style != wantPngStyle {
    29  		t.Errorf("Got dir style %q, want %q", style, wantPngStyle)
    30  	}
    31  }