MCPcopy Create free account
hub / github.com/github/gh-aw / TestExtractExperimentName

Function TestExtractExperimentName

pkg/cli/experiments_command_test.go:13–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestExtractExperimentName(t *testing.T) {
14 tests := []struct {
15 name string
16 ref string
17 expected string
18 }{
19 {
20 name: "remote ref with origin prefix",
21 ref: "origin/experiments/my-feature",
22 expected: "my-feature",
23 },
24 {
25 name: "local ref without origin prefix",
26 ref: "experiments/my-feature",
27 expected: "my-feature",
28 },
29 {
30 name: "nested experiment name",
31 ref: "experiments/team/feature-x",
32 expected: "team/feature-x",
33 },
34 {
35 name: "remote nested ref",
36 ref: "origin/experiments/team/feature-x",
37 expected: "team/feature-x",
38 },
39 {
40 name: "unrelated branch returns empty",
41 ref: "origin/main",
42 expected: "",
43 },
44 {
45 name: "feature branch without prefix returns empty",
46 ref: "feature/my-feature",
47 expected: "",
48 },
49 {
50 name: "bare experiments prefix returns empty",
51 ref: "experiments/",
52 expected: "",
53 },
54 }
55
56 for _, tt := range tests {
57 t.Run(tt.name, func(t *testing.T) {
58 got := extractExperimentName(tt.ref)
59 assert.Equal(t, tt.expected, got, "extractExperimentName(%q)", tt.ref)
60 })
61 }
62}
63
64func TestParseExperimentState(t *testing.T) {
65 tests := []struct {

Callers

nothing calls this directly

Calls 2

extractExperimentNameFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected