Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Added more tests to main_test.go #143

Merged
merged 2 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
package main

import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/sdboyer/gps"
)

func TestFindRoot(t *testing.T) {
Expand Down Expand Up @@ -40,6 +43,20 @@ func TestFindRoot(t *testing.T) {
t.Errorf("findProjectRoot on nonexistent subdir should still work and give %s, got %s", expect, got3)
}

root := "/"
returnedPath, projectRootErr := findProjectRoot(root)
if returnedPath != "" {
t.Errorf("findProjectRoot with path %s returned non empty string: %s", root, returnedPath)
}
if projectRootErr == nil {
t.Errorf("findProjectRoot with path %s should return error", root)
}
errStr := fmt.Sprintf("%v", projectRootErr.Error())
expectedStr := "could not find project manifest.json, use dep init to initiate a manifest"
if errStr != expectedStr {
t.Errorf("Incorrect errProjectNotFound error. Found: %s. Expected: %s", errStr, expectedStr)
}

// the following test does not work on windows because syscall.Stat does not
// return a "not a directory" error
if runtime.GOOS != "windows" {
Expand All @@ -49,3 +66,22 @@ func TestFindRoot(t *testing.T) {
}
}
}

func TestProjectMakeParams(t *testing.T) {
p := project{
absroot: "someroot",
importroot: gps.ProjectRoot("Some project root"),
m: &manifest{Ignores: []string{"ignoring this"}},
l: &lock{},
}

solveParam := p.makeParams()

if solveParam.Manifest != p.m {
t.Error("makeParams() returned gps.SolveParameters with incorrect Manifest")
}

if solveParam.Lock != p.l {
t.Error("makeParams() returned gps.SolveParameters with incorrect Lock")
}
}
4 changes: 2 additions & 2 deletions status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func TestStatusFormatVersion(t *testing.T) {

tests := map[gps.Version]string{
nil: "",
gps.NewBranch("master"): "branch master",
gps.NewVersion("1.0.0"): "1.0.0",
gps.NewBranch("master"): "branch master",
gps.NewVersion("1.0.0"): "1.0.0",
gps.Revision("flooboofoobooo"): "flooboo",
}
for version, expected := range tests {
Expand Down