build/maintner/gerrit_test.go

54 строки
1.4 KiB
Go

// 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 maintner
import "testing"
var statusTests = []struct {
msg string
want string
}{
{` Create change
Uploaded patch set 1.
Patch-set: 1 (draft)
Change-id: I38a08cacc17bcd9587475495111fe98f10d6875c
Subject: test: test
Branch: refs/heads/master
Status: draft
Topic:
Commit: fee468c613a70d89f60fb5d683b0f796aabecaac`, "draft"},
{` Update patch set 1
Change has been successfully cherry-picked as 117ac82c422a11e4dd5f4c14b50bafc1df840481 by Brad Fitzpatrick
Patch-set: 1
Status: merged
Submission-id: 16401-1446004855021-a20b3823`, "merged"},
{` Create patch set 8
Uploaded patch set 8: Patch Set 7 was rebased.
Patch-set: 8
Subject: devapp: initial support for App Engine Flex
Commit: 17839a9f284b473986f235ad2757a2b445d05068
Tag: autogenerated:gerrit:newPatchSet
Groups: 17839a9f284b473986f235ad2757a2b445d05068`, "new"},
}
func TestGetGerritStatus(t *testing.T) {
c := NewCorpus(&dummyMutationLogger{}, "")
c.AddGerrit("go.googlesource.com/build")
gp := c.gerrit.projects["go.googlesource.com/build"]
for _, tt := range statusTests {
gc := &GitCommit{Msg: tt.msg}
got := gp.getGerritStatus(gc, nil)
if got != tt.want {
t.Errorf("getGerritStatus msg:\n%s\ngot %s, want %s", tt.msg, got, tt.want)
}
}
}