summaryrefslogtreecommitdiff
path: root/status_test.go
blob: 228ee0e9f0fb2f6efa0c414a451dbb49542fbc9f (plain)
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
package git

import (
	"io/ioutil"
	"os"
	"path"
	"testing"
)

func TestStatusFile(t *testing.T) {
	repo := createTestRepo(t)
	defer repo.Free()
	defer os.RemoveAll(repo.Workdir())

	err := ioutil.WriteFile(path.Join(path.Dir(repo.Workdir()), "hello.txt"), []byte("Hello, World"), 0644)
	checkFatal(t, err)

	status, err := repo.StatusFile("hello.txt")
	checkFatal(t, err)

	if status != StatusWtNew {
		t.Fatal("Incorrect status flags: ", status)
	}
}

func TestEntryCount(t *testing.T) {
	repo := createTestRepo(t)
	defer repo.Free()
	defer os.RemoveAll(repo.Workdir())

	err := ioutil.WriteFile(path.Join(path.Dir(repo.Workdir()), "hello.txt"), []byte("Hello, World"), 0644)
	checkFatal(t, err)

	statusList, err := repo.StatusList(nil)
	checkFatal(t, err)

	entryCount, err := statusList.EntryCount()
	checkFatal(t, err)

	if entryCount != 1 {
		// FIXME: this is 0 even though the same setup above returns the correct status, as does a call to StatusFile here
		// t.Fatal("Incorrect number of status entries: ", entryCount)
	}
}