(t *testing.T)
| 123 | } |
| 124 | |
| 125 | func TestFormatExperimentLabel(t *testing.T) { |
| 126 | tests := []struct { |
| 127 | name string |
| 128 | exp *ExperimentData |
| 129 | expected string |
| 130 | }{ |
| 131 | { |
| 132 | name: "nil returns empty string", |
| 133 | exp: nil, |
| 134 | expected: "", |
| 135 | }, |
| 136 | { |
| 137 | name: "empty assignments returns empty string", |
| 138 | exp: &ExperimentData{Assignments: map[string]string{}}, |
| 139 | expected: "", |
| 140 | }, |
| 141 | { |
| 142 | name: "single experiment", |
| 143 | exp: &ExperimentData{Assignments: map[string]string{"style": "concise"}}, |
| 144 | expected: "style=concise", |
| 145 | }, |
| 146 | { |
| 147 | name: "multiple experiments sorted alphabetically", |
| 148 | exp: &ExperimentData{Assignments: map[string]string{"style": "concise", "caveman": "yes"}}, |
| 149 | expected: "caveman=yes, style=concise", |
| 150 | }, |
| 151 | { |
| 152 | name: "three experiments sorted", |
| 153 | exp: &ExperimentData{Assignments: map[string]string{"z": "1", "a": "2", "m": "3"}}, |
| 154 | expected: "a=2, m=3, z=1", |
| 155 | }, |
| 156 | } |
| 157 | |
| 158 | for _, tt := range tests { |
| 159 | t.Run(tt.name, func(t *testing.T) { |
| 160 | got := formatExperimentLabel(tt.exp) |
| 161 | assert.Equal(t, tt.expected, got, "formatExperimentLabel result mismatch") |
| 162 | }) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | func TestExperimentMatchesFilter(t *testing.T) { |
| 167 | exp := &ExperimentData{ |
nothing calls this directly
no test coverage detected