-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentify_test.go
78 lines (64 loc) · 2.17 KB
/
identify_test.go
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
75
76
77
78
// Copyright 2012, The gohg Authors. All rights reserved.
// Use of this source code is governed by a BSD style license
// that can be found in the LICENSE.md file.
package gohg
import (
// "errors"
// "fmt"
"testing"
// "os/exec"
)
func TestHgClient_Identify_EmptyRepo(t *testing.T) {
// GIVEN a new repo
hct := setup(t)
defer teardown(t, hct)
// AND the known result for 'hg identify' for a new repo
// var expected string = "000000000000 -1 default tip\n"
var expected string = "000000000000 tip\n"
// WHEN I call the 'hg identify' command on it
got, err := hct.Identify(nil, nil)
// got, err := hct.Id(nil, nil)
if err != nil {
t.Error(err)
}
// THEN the resulting info should be as expected
if string(got) != expected {
// if string(got) == expected { // to force an error, for testing
t.Fatalf("Test Identify: expected:\n%s\n but got:\n%s\n", expected, got)
}
}
// One test should be enough. If that one gets thru and returns a reasonable result,
// then the others are supposed to do that as well. After all, we're not testing the
// hg identify command as such here; only if we can get data from the Hg CS using that command.
// func TestHgClient_Identify_OneCset(t *testing.T) {
// hct := setup(t)
// // defer teardown(t, hct)
// var err error
// var cmd *exec.Cmd
// cmd = exec.Command("echo aaaa > " + hct.RepoRoot() + "\a")
// if err = cmd.Run(); err != nil {
// t.Fatal(err)
// }
// cmd = exec.Command(hct.HgExe(), "--cwd", hct.RepoRoot(), "ci", "-Am\"first commit\"")
// if err = cmd.Run(); err != nil {
// t.Fatal(err)
// }
// // use a regex to match the (any) hash
// // var expected string = "000000000000 tip\n"
// // got, err := hct.Identify(nil)
// // if err != nil {
// // t.Error(err)
// // }
// // if string(got) != expected {
// // t.Fatalf("Test Identify: expected:\n%s but got:\n%s\n", expected, got)
// // }
// }
// func TestHgClient_Identify_Dirty(t *testing.T) {
// // should show a "+" at the end of the hash
// }
// func TestHgClient_Identify_TwoParents(t *testing.T) {
// // should show 2 hashes, and no "+"
// }
// func TestHgClient_Identify_TwoParents_Dirty(t *testing.T) {
// // should show 2 hashes, and a "+"
// }