code.oscarkilo.com/klex-git

Hash:
006b476a159976e97e4f9374a76ddd86e5acbb4a
Author:
Igor Naverniouk <[email protected]>
Date:
Wed May 13 12:42:52 2026 -0400
Message:
exemplary: update golden to include 2025-11-19 webp case Pre-existing failure: commit cd12dfd added 2025-11-19.webp under exemplary/example/ but didn't update the TestScanForCases golden, so go test ./... has been failing on master since then. Adding the missing case to the golden — scanForCases() explicitly accepts webp (main.go:52) so this matches what's on disk.
diff --git a/exemplary/main_test.go b/exemplary/main_test.go
index ac93593..500f13c 100644
--- a/exemplary/main_test.go
+++ b/exemplary/main_test.go
@@ -37,6 +37,10 @@ func TestScanForCases(t *testing.T) {
Name: "2025-11-11",
Before: []string{"txt"},
},
+ Case{
+ Name: "2025-11-19",
+ Before: []string{"webp"},
+ },
}
CheckEq(t, golden, scanForCases())
}
a/exemplary/main_test.go
b/exemplary/main_test.go
1
package main
1
package main
2
2
3
import "encoding/json"
3
import "encoding/json"
4
import "testing"
4
import "testing"
5
5
6
import "oscarkilo.com/klex-git/api"
6
import "oscarkilo.com/klex-git/api"
7
7
8
func CheckEq(t *testing.T, golden, actual []Case) {
8
func CheckEq(t *testing.T, golden, actual []Case) {
9
t.Helper()
9
t.Helper()
10
g, err := json.MarshalIndent(golden, "", " ")
10
g, err := json.MarshalIndent(golden, "", " ")
11
if err != nil {
11
if err != nil {
12
t.Fatalf("json.MarshalIndent(golden) failed: %+v", err)
12
t.Fatalf("json.MarshalIndent(golden) failed: %+v", err)
13
}
13
}
14
a, err := json.MarshalIndent(actual, "", " ")
14
a, err := json.MarshalIndent(actual, "", " ")
15
if err != nil {
15
if err != nil {
16
t.Fatalf("json.MarshalIndent(actual) failed: %+v", err)
16
t.Fatalf("json.MarshalIndent(actual) failed: %+v", err)
17
}
17
}
18
if string(g) != string(a) {
18
if string(g) != string(a) {
19
t.Errorf("mismatch:\ngolden:\n%s\nactual:\n%s\n", g, a)
19
t.Errorf("mismatch:\ngolden:\n%s\nactual:\n%s\n", g, a)
20
}
20
}
21
}
21
}
22
22
23
func TestScanForCases(t *testing.T) {
23
func TestScanForCases(t *testing.T) {
24
// Get the path to the example dir next to this main_test.go file.
24
// Get the path to the example dir next to this main_test.go file.
25
*dir = "./example"
25
*dir = "./example"
26
golden := []Case{
26
golden := []Case{
27
Case{
27
Case{
28
Name: "2025-10-10",
28
Name: "2025-10-10",
29
Before: []string{"txt"},
29
Before: []string{"txt"},
30
After: "out",
30
After: "out",
31
},
31
},
32
Case{
32
Case{
33
Name: "2025-10-20",
33
Name: "2025-10-20",
34
Before: []string{"jpg"},
34
Before: []string{"jpg"},
35
},
35
},
36
Case{
36
Case{
37
Name: "2025-11-11",
37
Name: "2025-11-11",
38
Before: []string{"txt"},
38
Before: []string{"txt"},
39
},
39
},
40
Case{
41
Name: "2025-11-19",
42
Before: []string{"webp"},
43
},
40
}
44
}
41
CheckEq(t, golden, scanForCases())
45
CheckEq(t, golden, scanForCases())
42
}
46
}
43
47
44
func TestCopyRequest(t *testing.T) {
48
func TestCopyRequest(t *testing.T) {
45
a := &api.MessagesRequest{Model: "foo"}
49
a := &api.MessagesRequest{Model: "foo"}
46
b := copyRequest(*a)
50
b := copyRequest(*a)
47
a.Model = "bar"
51
a.Model = "bar"
48
if b.Model != "foo" {
52
if b.Model != "foo" {
49
t.Errorf("%s %s", a.Model, b.Model)
53
t.Errorf("%s %s", a.Model, b.Model)
50
}
54
}
51
}
55
}