/usr/share/gocode/src/github.com/Masterminds/vcs/repo_test.go is in golang-github-masterminds-vcs-dev 1.10.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | package vcs
import (
"fmt"
"io/ioutil"
"os"
"testing"
)
func ExampleNewRepo() {
remote := "https://github.com/Masterminds/vcs"
local, _ := ioutil.TempDir("", "go-vcs")
repo, _ := NewRepo(remote, local)
// Returns: instance of GitRepo
repo.Vcs()
// Returns Git as this is a Git repo
err := repo.Get()
// Pulls down a repo, or a checkout in the case of SVN, and returns an
// error if that didn't happen successfully.
if err != nil {
fmt.Println(err)
}
err = repo.UpdateVersion("master")
// Checkouts out a specific version. In most cases this can be a commit id,
// branch, or tag.
if err != nil {
fmt.Println(err)
}
}
func TestTypeSwitch(t *testing.T) {
// To test repo type switching we checkout as SVN and then try to get it as
// a git repo afterwards.
tempDir, err := ioutil.TempDir("", "go-vcs-svn-tests")
if err != nil {
t.Error(err)
}
defer func() {
err = os.RemoveAll(tempDir)
if err != nil {
t.Error(err)
}
}()
repo, err := NewSvnRepo("https://github.com/Masterminds/VCSTestRepo/trunk", tempDir+"/VCSTestRepo")
if err != nil {
t.Error(err)
}
err = repo.Get()
if err != nil {
t.Errorf("Unable to checkout SVN repo for repo switching tests. Err was %s", err)
}
_, err = NewRepo("https://github.com/Masterminds/VCSTestRepo", tempDir+"/VCSTestRepo")
if err != ErrWrongVCS {
t.Errorf("Not detecting repo switch from SVN to Git")
}
}
func TestDepInstalled(t *testing.T) {
i := depInstalled("git")
if !i {
t.Error("depInstalled not finding installed dep.")
}
i = depInstalled("thisreallyisntinstalled")
if i {
t.Error("depInstalled finding not installed dep.")
}
}
|