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

status: add project status #1367

Closed
wants to merge 14 commits into from
Closed
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
426 changes: 426 additions & 0 deletions cmd/dep/status.go

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions cmd/dep/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,100 @@ func TestValidateFlags(t *testing.T) {
})
}
}

func TestProjectStatusString(t *testing.T) {
ver1, _ := gps.NewSemverConstraintIC("v1.0.0")
ver05, _ := gps.NewSemverConstraintIC("v0.5.0")

testCases := []struct {
name string
ps projectStatus
wantString string
}{
{
name: "basic projectStatus",
ps: projectStatus{
Project: "github.com/x/y",
Version: "v1.0",
Constraints: projectConstraints{
{"gh.com/f/b", ver1},
{"btb.com/x/y", ver05},
},
Source: "github.com/x/y",
AltSource: "https://github.com/z/y",
PubVersions: pubVersions{
"semvers": []string{"v0.5", "v0.7", "v1.0", "v1.5"},
"branches": []string{"master", "dev"},
"nonsemvers": []string{"v1.0-rc1", "v1.5-rc"},
},
Revision: "some-rev",
LatestAllowed: "some-other-rev",
SourceType: "git",
Packages: []string{"github.com/x/y/pkgA", "github.com/x/y/pkgB", "github.com/x/y/pkgB/foo"},
ProjectImporters: projectImporters{
"github.com/a/b": true,
"github.com/foo/bar": true,
},
PackageImporters: packageImporters{
"github.com/x/y/pkgA": []string{"github.com/a/b/z", "github.com/foo/bar/k"},
"github.com/x/y/pkgB/foo": []string{"github.com/a/b/j"},
},
UpstreamExists: true,
UpstreamVersionExists: true,
},
wantString: `
PROJECT: github.com/x/y
VERSION: v1.0
CONSTRAINTS: ^0.5.0(btb.com/x/y)
^1.0.0(gh.com/f/b)
SOURCE: github.com/x/y
ALT SOURCE: https://github.com/z/y
PUB VERSION: branches: dev, master
nonsemvers: v1.0-rc1, v1.5-rc
semvers: v0.5, v0.7, v1.0, v1.5
REVISION: some-rev
LATEST ALLOWED: some-other-rev
SOURCE TYPE: git
PACKAGES: github.com/x/y/pkgA, github.com/x/y/pkgB, github.com/x/y/pkgB/foo
PROJECT IMPORTERS: github.com/a/b, github.com/foo/bar
PACKAGE IMPORTERS: github.com/x/y/pkgA
github.com/a/b/z
github.com/foo/bar/k
github.com/x/y/pkgB/foo
github.com/a/b/j
UPSTREAM EXISTS: yes
UPSTREAM VERSION EXISTS: yes`,
},
{
name: "projectStatus with no upstream exists",
ps: projectStatus{
UpstreamExists: false,
UpstreamVersionExists: false,
},
wantString: `
PROJECT:
VERSION:
CONSTRAINTS:
SOURCE:
ALT SOURCE:
PUB VERSION:
REVISION:
LATEST ALLOWED:
SOURCE TYPE:
PACKAGES:
PROJECT IMPORTERS:
PACKAGE IMPORTERS:
UPSTREAM EXISTS: no
UPSTREAM VERSION EXISTS: no`,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
gotString := tc.ps.String()
if gotString != tc.wantString {
t.Errorf("unexpected projectStatus string: \n\t(GOT): %v\n\t(WNT): %v", gotString, tc.wantString)
}
})
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[constraint]]
branch = "master"
name = "github.com/darkowlzz/deptest-project-status"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"

[[constraint]]
name = "github.com/sdboyer/deptestdos"
version = "2.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/darkowlzz/deptest-project-status/pkgfoo"
_ "github.com/sdboyer/deptest"
_ "github.com/sdboyer/deptestdos"
)

func main() {}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[constraint]]
branch = "master"
name = "github.com/darkowlzz/deptest-project-status"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"

[[constraint]]
name = "github.com/sdboyer/deptestdos"
version = "2.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/darkowlzz/deptest-project-status/pkgfoo"
_ "github.com/sdboyer/deptest"
_ "github.com/sdboyer/deptestdos"
)

func main() {}
19 changes: 19 additions & 0 deletions cmd/dep/testdata/harness_tests/status/project_status/stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

PROJECT: github.com/sdboyer/deptest
VERSION: v1.0.0
CONSTRAINTS:
SOURCE: github.com/sdboyer/deptest
ALT SOURCE:
PUB VERSION: branches: master
nonsemvers:
semvers: v0.8.0, v0.8.1, v1.0.0
REVISION: ff2948a2ac8f538c4ecd55962e919d1e13e74baf
LATEST ALLOWED: ff2948a2ac8f538c4ecd55962e919d1e13e74baf
SOURCE TYPE: git
PACKAGES: github.com/sdboyer/deptest
PROJECT IMPORTERS: github.com/darkowlzz/deptest-project-status, github.com/sdboyer/deptestdos
PACKAGE IMPORTERS: github.com/sdboyer/deptest
github.com/darkowlzz/deptest-project-status/pkgfoo
github.com/sdboyer/deptestdos
UPSTREAM EXISTS: yes
UPSTREAM VERSION EXISTS: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"commands": [
["ensure"],
["status", "github.com/sdboyer/deptest"]
],
"error-expected": "",
"vendor-final": [
"github.com/darkowlzz/deptest-project-status",
"github.com/sdboyer/deptest",
"github.com/sdboyer/deptestdos"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[constraint]]
branch = "master"
name = "github.com/darkowlzz/deptest-project-status"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"

[[constraint]]
name = "github.com/sdboyer/deptestdos"
version = "2.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/darkowlzz/deptest-project-status/pkgfoo"
_ "github.com/sdboyer/deptest"
_ "github.com/sdboyer/deptestdos"
)

func main() {}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[constraint]]
branch = "master"
name = "github.com/darkowlzz/deptest-project-status"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"

[[constraint]]
name = "github.com/sdboyer/deptestdos"
version = "2.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/darkowlzz/deptest-project-status/pkgfoo"
_ "github.com/sdboyer/deptest"
_ "github.com/sdboyer/deptestdos"
)

func main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"commands": [
["ensure"],
["status", "github.com/golang/dep"]
],
"error-expected": "github.com/golang/dep is not in the lock file. Ensure that the project is being used and run `dep ensure` to generate a new lock file.",
"vendor-final": [
"github.com/darkowlzz/deptest-project-status",
"github.com/sdboyer/deptest",
"github.com/sdboyer/deptestdos"
]
}
8 changes: 8 additions & 0 deletions gps/solve_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,14 @@ func (sm *depspecSourceManager) SourceURLsForPath(ip string) ([]*url.URL, error)
return nil, fmt.Errorf("dummy sm doesn't implement SourceURLsForPath")
}

func (sm *depspecSourceManager) GetSourceType(id ProjectIdentifier) (SourceType, error) {
return InvalidSource, fmt.Errorf("dummy sm doesn't implement GetSourceType")
}

func (sm *depspecSourceManager) ExistsUpstream(id ProjectIdentifier) (bool, error) {
return false, fmt.Errorf("dummy sm doesn't implement ExistsUpstream")
}

func (sm *depspecSourceManager) rootSpec() depspec {
return sm.specs[0]
}
Expand Down
Loading