-
Notifications
You must be signed in to change notification settings - Fork 10
/
helpers.go
39 lines (34 loc) · 1.06 KB
/
helpers.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
package e2e_tests
import (
"os"
"testing"
"time"
"github.com/aviator-co/av/internal/git"
"github.com/aviator-co/av/internal/meta"
"github.com/aviator-co/av/internal/meta/jsonfiledb"
"github.com/stretchr/testify/require"
)
func RequireCurrentBranchName(t *testing.T, repo *git.Repo, name string) {
currentBranch, err := repo.CurrentBranchName()
require.NoError(t, err, "failed to determine current branch name")
require.Equal(
t,
name,
currentBranch,
"expected current branch to be %q, got %q",
name,
currentBranch,
)
}
func GetFetchHeadTimestamp(t *testing.T, repo *git.Repo) time.Time {
fileInfo, err := os.Stat(repo.Dir() + "/.git/FETCH_HEAD")
require.NoError(t, err, "failed to stat .git/FETCH_HEAD")
return fileInfo.ModTime()
}
func GetStoredParentBranchState(t *testing.T, repo *git.Repo, name string) meta.BranchState {
// We shouldn't do this as part of an E2E test, but it's hard to ensure otherwise.
db, err := jsonfiledb.OpenRepo(repo)
require.NoError(t, err, "failed to open repo db")
br, _ := db.ReadTx().Branch(name)
return br.Parent
}