Files
coder/.github/workflows/prcontext/parse_test.go
T
Ammar Bandukwala 60de8d0279 ci: add skip directives for long tests (#3151)
This PR introduces many CI optimizations:

1. The `[ci-skip]` PR body directive to skip the Postgres and end to end tests
2. Improved caching that cuts the Go test matrix in half
3. Increasing Go test parallelism for ~20% gains
4. Enable caching in webpack (4x frontend build)
2022-07-24 14:33:58 -05:00

39 lines
1.0 KiB
Go

package main
import (
"reflect"
"testing"
)
func Test_parseBody_basic(t *testing.T) {
parseBody(`
This is a test PR.
[ci-skip postgres windows]
`)
}
func Test_parseBody(t *testing.T) {
type args struct {
body string
}
tests := []struct {
name string
args args
wantSkips []string
}{
{"no directive", args{"test pr 123\n\n"}, nil},
{"single dir single skip", args{"test pr [ci-skip dog] 123\n\n"}, []string{"dog"}},
{"double dir double skip", args{"test pr [ci-skip dog] [ci-skip cat] 123\n\n"}, []string{"dog", "cat"}},
{"single dir double skip", args{"test pr [ci-skip test/go/postgres cat] 123\n\n"}, []string{"test/go/postgres", "cat"}},
{"confuse", args{"ci ci [ci-skip] dog [ci-skip test/go/postgres test/e2e/ubuntu-latest] 123\n\n"}, []string{"test/go/postgres", "test/e2e/ubuntu-latest"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotSkips := parseBody(tt.args.body); !reflect.DeepEqual(gotSkips, tt.wantSkips) {
t.Errorf("parseBody() = %v, want %v", gotSkips, tt.wantSkips)
}
})
}
}