Permalink
Browse files

Introduce pin command tests

  • Loading branch information...
1 parent 2f4fbf8 commit b94c71065fabafab4496d4a02bb5b29f4c033d0f @gsamokovarov committed Apr 30, 2017
Showing with 34 additions and 0 deletions.
  1. +34 −0 cmd/pin_test.go
View
@@ -0,0 +1,34 @@
+package cmd
+
+import (
+ "os"
+ p "path"
+ "testing"
+
+ "github.com/gsamokovarov/jump/cli"
+ s "github.com/gsamokovarov/jump/scoring"
+)
+
+func Test_pinCmd(t *testing.T) {
+ p1 := p.Join(td, "web")
+ p2 := p.Join(td, "web-console")
+
+ conf := &testConfig{
+ Entries: s.Entries{
+ s.Entry{p1, &s.Score{Weight: 100, Age: s.Now}},
+ s.Entry{p2, &s.Score{Weight: 90, Age: s.Now}},
+ },
+ }
+
+ pinCmd(cli.Args{"sait", p2}, conf)
+
+ output := capture(&os.Stdout, func() {
+ cdCmd(cli.Args{"sait"}, conf)
+ })
+
+ expectedPath := p2 + "\n"
+
+ if output != expectedPath {
+ t.Fatalf("Expected path to be %s, got %s", expectedPath, output)
+ }
+}

0 comments on commit b94c710

Please sign in to comment.