github.com/exercism/v2-configlet@v3.9.2+incompatible/cmd/tree_test.go (about)

     1  package cmd
     2  
     3  // Because the tree cmd concerns itself with writing to stdout the
     4  // more tests are in the example tests. This is concerned with non-output
     5  // related situations.
     6  import (
     7  	"path/filepath"
     8  	"testing"
     9  )
    10  
    11  func TestGivenTrackPath(t *testing.T) {
    12  	err := treeTrack(filepath.FromSlash("../fixtures/tree"))
    13  
    14  	if err != nil {
    15  		t.Error("should discover config.json given path to directory.")
    16  	}
    17  }
    18  
    19  func TestGivenFilename(t *testing.T) {
    20  	err := treeTrack(filepath.FromSlash("../fixtures/tree/config.json"))
    21  
    22  	if err != nil {
    23  		t.Error("should open config.json given path to file.")
    24  	}
    25  }
    26  
    27  func TestMissingFileError(t *testing.T) {
    28  	err := treeTrack(filepath.FromSlash("../fixtures/tree/non-existing-config.json"))
    29  
    30  	if err == nil {
    31  		t.Error("should error for non-existing configuration file.")
    32  	}
    33  }