dawn-cmake/tools/src/gerrit/gerrit_test.go
Ben Clayton 526087bde7 tools: Add more functionality to gerrit package
Add Patchset.RefsChanges(). Returns the 'refs/changes/X/Y/Z' string
for the given patchset.

Add []FileComment parameter to Gerrit.Comment(), allowing the posting
of comments on particular lines of the change.

Bug: dawn:1342
Change-Id: Ia4113a158b285c606b2c6c520cef6c9e8030fae7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88314
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2022-04-29 15:15:43 +00:00

65 lines
1.4 KiB
Go

// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package gerrit_test
import (
"testing"
"dawn.googlesource.com/dawn/tools/src/gerrit"
"github.com/google/go-cmp/cmp"
)
func TestPatchsetRefsChanges(t *testing.T) {
type Test struct {
in gerrit.Patchset
expect string
}
for _, test := range []Test{
{
in: gerrit.Patchset{
Change: 123456,
Patchset: 42,
},
expect: `refs/changes/56/123456/42`,
},
{
in: gerrit.Patchset{
Change: 1234,
Patchset: 42,
},
expect: `refs/changes/34/1234/42`,
},
{
in: gerrit.Patchset{
Change: 12,
Patchset: 42,
},
expect: `refs/changes/12/12/42`,
},
{
in: gerrit.Patchset{
Change: 1,
Patchset: 42,
},
expect: `refs/changes/01/1/42`,
},
} {
got := test.in.RefsChanges()
if diff := cmp.Diff(got, test.expect); diff != "" {
t.Errorf("%v.RefsChanges() was not as expected:\n%v", test.in, diff)
}
}
}