diff --git a/.gitignore b/.gitignore index 89a7f70..e7031de 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ go.work go.work.sum .env -cmd/tui/freeze-tui +cmd/tui/shutter +cmd/shutter/shutter diff --git a/README.md b/README.md index 5b3f286..08a889f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A [birdie](https://github.com/giacomocavalieri/birdie) and [insta](https://githu ## Installation ```sh -go get github.com/ptdewey/freeze +go get github.com/ptdewey/shutter ``` ## Usage @@ -21,7 +21,7 @@ package package_test func TestSomething(t *testing.T) { result := SomeFunction("foo") - freeze.Snap(t, result) + shutter.Snap(t, result) } ``` @@ -38,9 +38,9 @@ func TestUserAPI(t *testing.T) { user := api.GetUser("123") // Replace UUIDs and timestamps with placeholders - freeze.SnapWithOptions(t, "user", []freeze.SnapshotOption{ - freeze.ScrubUUIDs(), - freeze.ScrubTimestamps(), + shutter.SnapWithOptions(t, "user", []shutter.SnapshotOption{ + shutter.ScrubUUIDs(), + shutter.ScrubTimestamps(), }, user) } ``` @@ -60,13 +60,13 @@ func TestUserAPI(t *testing.T) { ```go // Using regex patterns -freeze.RegexScrubber(`user-\d+`, "") +shutter.RegexScrubber(`user-\d+`, "") // Using exact string matching -freeze.ExactMatchScrubber("secret_value", "") +shutter.ExactMatchScrubber("secret_value", "") // Using custom functions -freeze.CustomScrubber(func(content string) string { +shutter.CustomScrubber(func(content string) string { return strings.ReplaceAll(content, "localhost", "") }) ``` @@ -80,10 +80,10 @@ func TestAPIResponse(t *testing.T) { response := api.GetData() // Ignore sensitive fields and null values - freeze.SnapJSONWithOptions(t, "response", response, []freeze.SnapshotOption{ - freeze.IgnoreSensitiveKeys(), - freeze.IgnoreNullValues(), - freeze.IgnoreKeys("created_at", "updated_at"), + shutter.SnapJSONWithOptions(t, "response", response, []shutter.SnapshotOption{ + shutter.IgnoreSensitiveKeys(), + shutter.IgnoreNullValues(), + shutter.IgnoreKeys("created_at", "updated_at"), }) } ``` @@ -97,19 +97,19 @@ func TestAPIResponse(t *testing.T) { ```go // Ignore specific keys -freeze.IgnoreKeys("id", "timestamp", "version") +shutter.IgnoreKeys("id", "timestamp", "version") // Ignore key-value pairs -freeze.IgnoreKeyValue("status", "pending") +shutter.IgnoreKeyValue("status", "pending") // Ignore keys matching a regex pattern -freeze.IgnoreKeysMatching(`^_.*`) // Ignore all keys starting with underscore +shutter.IgnoreKeysMatching(`^_.*`) // Ignore all keys starting with underscore // Ignore specific values -freeze.IgnoreValues("null", "undefined", "") +shutter.IgnoreValues("null", "undefined", "") // Using custom functions -freeze.CustomIgnore(func(key, value string) bool { +shutter.CustomIgnore(func(key, value string) bool { return strings.HasPrefix(key, "temp_") }) ``` @@ -122,16 +122,16 @@ You can combine multiple scrubbers and ignore patterns: func TestComplexData(t *testing.T) { data := generateTestData() - freeze.SnapWithOptions(t, "data", []freeze.SnapshotOption{ + shutter.SnapWithOptions(t, "data", []shutter.SnapshotOption{ // Scrubbers - freeze.ScrubUUIDs(), - freeze.ScrubTimestamps(), - freeze.ScrubEmails(), + shutter.ScrubUUIDs(), + shutter.ScrubTimestamps(), + shutter.ScrubEmails(), // Ignore patterns - freeze.IgnoreSensitiveKeys(), - freeze.IgnoreKeys("debug_info"), - freeze.IgnoreNullValues(), + shutter.IgnoreSensitiveKeys(), + shutter.IgnoreKeys("debug_info"), + shutter.IgnoreNullValues(), }, data) } ``` @@ -142,13 +142,13 @@ Three snapshot functions support options: ```go // For general values (structs, maps, slices, etc.) -freeze.SnapWithOptions(t, "title", []freeze.SnapshotOption{...}, value) +shutter.SnapWithOptions(t, "title", []shutter.SnapshotOption{...}, value) // For JSON strings -freeze.SnapJSONWithOptions(t, "title", jsonString, []freeze.SnapshotOption{...}) +shutter.SnapJSONWithOptions(t, "title", jsonString, []shutter.SnapshotOption{...}) // For plain strings -freeze.SnapStringWithOptions(t, "title", content, []freeze.SnapshotOption{...}) +shutter.SnapStringWithOptions(t, "title", content, []shutter.SnapshotOption{...}) ``` ### Reviewing Snapshots @@ -156,27 +156,27 @@ freeze.SnapStringWithOptions(t, "title", content, []freeze.SnapshotOption{...}) To review a set of snapshots, run: ```sh -go run github.com/ptdewey/freeze/cmd/freeze review +go run github.com/ptdewey/shutter/cmd/shutter review ``` Freeze can also be used programmatically: ```go -// Example: tools/freeze/main.go +// Example: tools/shutter/main.go package main -import "github.com/ptdewey/freeze" +import "github.com/ptdewey/shutter" func main() { // This will start the CLI review tool - freeze.Review() + shutter.Review() } ``` Which can then be run with: ```sh -go run tools/freeze/main.go +go run tools/shutter/main.go ``` Freeze also includes (in a separate Go module) a [Bubbletea](https://github.com/charmbracelet/bubbletea) TUI in [cmd/tui/main.go](./cmd/tui/main.go). @@ -185,7 +185,7 @@ Freeze also includes (in a separate Go module) a [Bubbletea](https://github.com/ ### TUI Usage ```sh -go run github.com/ptdewey/freeze/cmd/tui review +go run github.com/ptdewey/shutter/cmd/tui review ``` #### Interactive Controls @@ -202,10 +202,10 @@ go run github.com/ptdewey/freeze/cmd/tui review ```sh # Accept all new snapshots without review -go run github.com/ptdewey/freeze/cmd/tui accept-all +go run github.com/ptdewey/shutter/cmd/tui accept-all # Reject all new snapshots without review -go run github.com/ptdewey/freeze/cmd/tui reject-all +go run github.com/ptdewey/shutter/cmd/tui reject-all ``` ## Disclaimer diff --git a/__snapshots__/test_complex_json_structure.snap b/__snapshots__/test_complex_json_structure.snap index 381c0be..4b68d82 100644 --- a/__snapshots__/test_complex_json_structure.snap +++ b/__snapshots__/test_complex_json_structure.snap @@ -1,7 +1,7 @@ --- title: Complex JSON Structure test_name: TestComplexJsonStructure -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_complex_nested_structure.snap b/__snapshots__/test_complex_nested_structure.snap index f4a1406..1c5e4bf 100644 --- a/__snapshots__/test_complex_nested_structure.snap +++ b/__snapshots__/test_complex_nested_structure.snap @@ -1,14 +1,14 @@ --- title: Complex Nested Structure test_name: TestComplexNestedStructure -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- -freeze_test.Post{ +shutter_test.Post{ ID: 100, Title: "Introduction to Go Snapshot Testing", Content: "This is a comprehensive guide to snapshot testing in Go...", - Author: freeze_test.User{ + Author: shutter_test.User{ ID: 1, Username: "john_doe", Email: "john@example.com", @@ -39,7 +39,7 @@ freeze_test.Post{ "snapshots", "best-practices", }, - Comments: []freeze_test.Comment{ + Comments: []shutter_test.Comment{ { ID: 1, Author: "alice", @@ -49,7 +49,7 @@ freeze_test.Post{ ext: 63810858120, loc: (*time.Location)(nil), }, - Replies: []freeze_test.Comment{ + Replies: []shutter_test.Comment{ { ID: 2, Author: "bob", @@ -59,7 +59,7 @@ freeze_test.Post{ ext: 63810863100, loc: (*time.Location)(nil), }, - Replies: []freeze_test.Comment{ + Replies: []shutter_test.Comment{ }, }, }, @@ -73,7 +73,7 @@ freeze_test.Post{ ext: 63810927000, loc: (*time.Location)(nil), }, - Replies: []freeze_test.Comment{ + Replies: []shutter_test.Comment{ }, }, }, diff --git a/__snapshots__/test_deeply_nested_json.snap b/__snapshots__/test_deeply_nested_json.snap index 4471415..c97f438 100644 --- a/__snapshots__/test_deeply_nested_json.snap +++ b/__snapshots__/test_deeply_nested_json.snap @@ -1,7 +1,7 @@ --- title: Deeply Nested JSON test_name: TestDeeplyNestedJson -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_go_struct_marshalled_to_json.snap b/__snapshots__/test_go_struct_marshalled_to_json.snap index 579c800..44bc091 100644 --- a/__snapshots__/test_go_struct_marshalled_to_json.snap +++ b/__snapshots__/test_go_struct_marshalled_to_json.snap @@ -1,7 +1,7 @@ --- title: Go Struct Marshalled to JSON test_name: TestGoStructMarshalledToJson -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_json_array_of_objects.snap b/__snapshots__/test_json_array_of_objects.snap index 482d882..09e5f1e 100644 --- a/__snapshots__/test_json_array_of_objects.snap +++ b/__snapshots__/test_json_array_of_objects.snap @@ -1,7 +1,7 @@ --- title: JSON Array of Objects test_name: TestJsonArrayOfObjects -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- []interface{}{ diff --git a/__snapshots__/test_json_numbers.snap b/__snapshots__/test_json_numbers.snap index 6d058ac..a14c213 100644 --- a/__snapshots__/test_json_numbers.snap +++ b/__snapshots__/test_json_numbers.snap @@ -1,7 +1,7 @@ --- title: JSON Numbers test_name: TestJsonNumbers -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_json_object.snap b/__snapshots__/test_json_object.snap index 59869ae..3c1c7b3 100644 --- a/__snapshots__/test_json_object.snap +++ b/__snapshots__/test_json_object.snap @@ -1,7 +1,7 @@ --- title: JSON Object test_name: TestJsonObject -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_json_with_mixed_arrays.snap b/__snapshots__/test_json_with_mixed_arrays.snap index 268d4ea..6989950 100644 --- a/__snapshots__/test_json_with_mixed_arrays.snap +++ b/__snapshots__/test_json_with_mixed_arrays.snap @@ -1,7 +1,7 @@ --- title: JSON with Mixed Arrays test_name: TestJsonWithMixedArrays -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_json_with_special_characters.snap b/__snapshots__/test_json_with_special_characters.snap index 2fa227b..5253642 100644 --- a/__snapshots__/test_json_with_special_characters.snap +++ b/__snapshots__/test_json_with_special_characters.snap @@ -1,7 +1,7 @@ --- title: JSON with Special Characters test_name: TestJsonWithSpecialCharacters -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_json_with_various_types.snap b/__snapshots__/test_json_with_various_types.snap index adfed38..b1185d4 100644 --- a/__snapshots__/test_json_with_various_types.snap +++ b/__snapshots__/test_json_with_various_types.snap @@ -1,7 +1,7 @@ --- title: JSON with Various Types test_name: TestJsonWithVariousTypes -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_large_json.snap b/__snapshots__/test_large_json.snap index aafb69f..3140ee3 100644 --- a/__snapshots__/test_large_json.snap +++ b/__snapshots__/test_large_json.snap @@ -1,7 +1,7 @@ --- title: Large JSON Structure test_name: TestLargeJson -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_map.snap b/__snapshots__/test_map.snap index 385f7ab..5afde52 100644 --- a/__snapshots__/test_map.snap +++ b/__snapshots__/test_map.snap @@ -1,7 +1,7 @@ --- title: Map Test test_name: TestMap -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_multiple_complex_structures.snap b/__snapshots__/test_multiple_complex_structures.snap index dcd8a32..8074bea 100644 --- a/__snapshots__/test_multiple_complex_structures.snap +++ b/__snapshots__/test_multiple_complex_structures.snap @@ -1,10 +1,10 @@ --- title: Multiple Complex Structures test_name: TestMultipleComplexStructures -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- -[]freeze_test.User{ +[]shutter_test.User{ { ID: 1, Username: "alice", diff --git a/__snapshots__/test_nested_maps_and_slices.snap b/__snapshots__/test_nested_maps_and_slices.snap index 090d7f2..cc71a27 100644 --- a/__snapshots__/test_nested_maps_and_slices.snap +++ b/__snapshots__/test_nested_maps_and_slices.snap @@ -1,7 +1,7 @@ --- title: Nested Maps and Slices test_name: TestNestedMapsAndSlices -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- map[string]interface{}{ diff --git a/__snapshots__/test_snap_custom_type.snap b/__snapshots__/test_snap_custom_type.snap index 647c9ef..379d393 100644 --- a/__snapshots__/test_snap_custom_type.snap +++ b/__snapshots__/test_snap_custom_type.snap @@ -1,10 +1,10 @@ --- title: Custom Type Test test_name: TestSnapCustomType -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- -freeze_test.CustomStruct{ +shutter_test.CustomStruct{ Name: "Alice", Age: 30, } diff --git a/__snapshots__/test_snap_json_array_of_objects.snap b/__snapshots__/test_snap_json_array_of_objects.snap index 18e0734..e52116d 100644 --- a/__snapshots__/test_snap_json_array_of_objects.snap +++ b/__snapshots__/test_snap_json_array_of_objects.snap @@ -1,29 +1,29 @@ --- title: SnapJSON Array of Objects test_name: TestSnapJsonArrayOfObjects -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- [ - { - "id": 1, - "type": "post", - "title": "First Post", - "views": 150, - "likes": 42 - }, - { - "id": 2, - "type": "post", - "title": "Second Post", - "views": 280, - "likes": 75 - }, - { - "id": 3, - "type": "post", - "title": "Third Post", - "views": 450, - "likes": 120 - } - ] \ No newline at end of file + { + "id": 1, + "likes": 42, + "title": "First Post", + "type": "post", + "views": 150 + }, + { + "id": 2, + "likes": 75, + "title": "Second Post", + "type": "post", + "views": 280 + }, + { + "id": 3, + "likes": 120, + "title": "Third Post", + "type": "post", + "views": 450 + } +] \ No newline at end of file diff --git a/__snapshots__/test_snap_json_basic.snap b/__snapshots__/test_snap_json_basic.snap index 6f89bc6..63e8442 100644 --- a/__snapshots__/test_snap_json_basic.snap +++ b/__snapshots__/test_snap_json_basic.snap @@ -1,12 +1,12 @@ --- title: SnapJSON Basic Object test_name: TestSnapJsonBasic -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "name": "John Doe", - "email": "john@example.com", - "age": 30, - "verified": true - } \ No newline at end of file + "age": 30, + "email": "john@example.com", + "name": "John Doe", + "verified": true +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_compact_format.snap b/__snapshots__/test_snap_json_compact_format.snap index 7cd2a75..32c0e5d 100644 --- a/__snapshots__/test_snap_json_compact_format.snap +++ b/__snapshots__/test_snap_json_compact_format.snap @@ -1,7 +1,16 @@ --- title: SnapJSON Compact Format test_name: TestSnapJsonCompactFormat -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- -{"id":1,"name":"Product","price":99.99,"in_stock":true,"tags":["electronics","gadgets"]} \ No newline at end of file +{ + "id": 1, + "in_stock": true, + "name": "Product", + "price": 99.99, + "tags": [ + "electronics", + "gadgets" + ] +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_complex_a_p_i.snap b/__snapshots__/test_snap_json_complex_a_p_i.snap index f3140c7..f032d71 100644 --- a/__snapshots__/test_snap_json_complex_a_p_i.snap +++ b/__snapshots__/test_snap_json_complex_a_p_i.snap @@ -1,42 +1,42 @@ --- title: SnapJSON Complex API Response test_name: TestSnapJsonComplexAPI -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "status": "success", - "code": 200, - "data": { - "users": [ - { - "id": 1, - "name": "Alice", - "role": "admin", - "department": "Engineering", - "active": true - }, - { - "id": 2, - "name": "Bob", - "role": "user", - "department": "Sales", - "active": true - }, - { - "id": 3, - "name": "Charlie", - "role": "user", - "department": "Marketing", - "active": false - } - ], - "pagination": { - "page": 1, - "per_page": 10, - "total": 3, - "total_pages": 1 - } - }, - "timestamp": "2023-11-18T21:45:30Z" - } \ No newline at end of file + "code": 200, + "data": { + "pagination": { + "page": 1, + "per_page": 10, + "total": 3, + "total_pages": 1 + }, + "users": [ + { + "active": true, + "department": "Engineering", + "id": 1, + "name": "Alice", + "role": "admin" + }, + { + "active": true, + "department": "Sales", + "id": 2, + "name": "Bob", + "role": "user" + }, + { + "active": false, + "department": "Marketing", + "id": 3, + "name": "Charlie", + "role": "user" + } + ] + }, + "status": "success", + "timestamp": "2023-11-18T21:45:30Z" +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_empty_structures.snap b/__snapshots__/test_snap_json_empty_structures.snap index bbae9f9..2575950 100644 --- a/__snapshots__/test_snap_json_empty_structures.snap +++ b/__snapshots__/test_snap_json_empty_structures.snap @@ -1,18 +1,18 @@ --- title: SnapJSON Empty Structures test_name: TestSnapJsonEmptyStructures -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "empty_array": [], - "empty_object": {}, - "empty_string": "", - "zero": 0, - "false_value": false, - "null_value": null, - "nested": { - "empty": [], - "also_empty": {} - } - } \ No newline at end of file + "empty_array": [], + "empty_object": {}, + "empty_string": "", + "false_value": false, + "nested": { + "also_empty": {}, + "empty": [] + }, + "null_value": null, + "zero": 0 +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_large_nested_structure.snap b/__snapshots__/test_snap_json_large_nested_structure.snap index 1e459e5..6cd201f 100644 --- a/__snapshots__/test_snap_json_large_nested_structure.snap +++ b/__snapshots__/test_snap_json_large_nested_structure.snap @@ -1,63 +1,103 @@ --- title: SnapJSON Large Nested Structure test_name: TestSnapJsonLargeNestedStructure -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "organization": { - "name": "TechCorp", - "id": "org_123", - "departments": [ - { - "name": "Engineering", - "manager": "Alice", - "teams": [ - { - "name": "Backend", - "lead": "John", - "members": [ - {"id": 1, "name": "John", "level": "senior"}, - {"id": 2, "name": "Jane", "level": "mid"} - ], - "projects": [ - {"id": "proj_1", "name": "API Service", "status": "active"}, - {"id": "proj_2", "name": "Database Optimization", "status": "planning"} - ] - }, - { - "name": "Frontend", - "lead": "Bob", - "members": [ - {"id": 3, "name": "Bob", "level": "senior"}, - {"id": 4, "name": "Carol", "level": "junior"} - ], - "projects": [ - {"id": "proj_3", "name": "Web App", "status": "active"} - ] - } - ] - }, - { - "name": "Sales", - "manager": "Charlie", - "teams": [ - { - "name": "Enterprise", - "lead": "Dave", - "members": [ - {"id": 5, "name": "Dave", "level": "senior"}, - {"id": 6, "name": "Eve", "level": "mid"} - ], - "projects": [] - } - ] - } - ], - "metadata": { - "founded": "2020", - "employees": 150, - "locations": ["USA", "EU", "APAC"] - } - } - } \ No newline at end of file + "organization": { + "departments": [ + { + "manager": "Alice", + "name": "Engineering", + "teams": [ + { + "lead": "John", + "members": [ + { + "id": 1, + "level": "senior", + "name": "John" + }, + { + "id": 2, + "level": "mid", + "name": "Jane" + } + ], + "name": "Backend", + "projects": [ + { + "id": "proj_1", + "name": "API Service", + "status": "active" + }, + { + "id": "proj_2", + "name": "Database Optimization", + "status": "planning" + } + ] + }, + { + "lead": "Bob", + "members": [ + { + "id": 3, + "level": "senior", + "name": "Bob" + }, + { + "id": 4, + "level": "junior", + "name": "Carol" + } + ], + "name": "Frontend", + "projects": [ + { + "id": "proj_3", + "name": "Web App", + "status": "active" + } + ] + } + ] + }, + { + "manager": "Charlie", + "name": "Sales", + "teams": [ + { + "lead": "Dave", + "members": [ + { + "id": 5, + "level": "senior", + "name": "Dave" + }, + { + "id": 6, + "level": "mid", + "name": "Eve" + } + ], + "name": "Enterprise", + "projects": [] + } + ] + } + ], + "id": "org_123", + "metadata": { + "employees": 150, + "founded": "2020", + "locations": [ + "USA", + "EU", + "APAC" + ] + }, + "name": "TechCorp" + } +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_mixed_types.snap b/__snapshots__/test_snap_json_mixed_types.snap index d139425..522cc49 100644 --- a/__snapshots__/test_snap_json_mixed_types.snap +++ b/__snapshots__/test_snap_json_mixed_types.snap @@ -1,25 +1,41 @@ --- title: SnapJSON Mixed Types test_name: TestSnapJsonMixedTypes -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "mixed_array": [ - "string", - 123, - 45.67, - true, - false, - null, - {"nested": "object"}, - [1, 2, 3] - ], - "complex": [ - {"type": "user", "id": 1}, - {"type": "post", "id": 100}, - [1, 2, 3], - "string", - null - ] - } \ No newline at end of file + "complex": [ + { + "id": 1, + "type": "user" + }, + { + "id": 100, + "type": "post" + }, + [ + 1, + 2, + 3 + ], + "string", + null + ], + "mixed_array": [ + "string", + 123, + 45.67, + true, + false, + null, + { + "nested": "object" + }, + [ + 1, + 2, + 3 + ] + ] +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_real_world_example.snap b/__snapshots__/test_snap_json_real_world_example.snap index a7474c5..27d3ea6 100644 --- a/__snapshots__/test_snap_json_real_world_example.snap +++ b/__snapshots__/test_snap_json_real_world_example.snap @@ -1,80 +1,84 @@ --- title: SnapJSON Real World Example test_name: TestSnapJsonRealWorldExample -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "success": true, - "data": { - "product": { - "id": "prod_12345", - "name": "Premium Wireless Headphones", - "sku": "PWH-001", - "description": "High-quality wireless headphones with noise cancellation", - "price": { - "amount": 199.99, - "currency": "USD", - "discount": 10, - "final_price": 179.99 - }, - "inventory": { - "total": 500, - "available": 425, - "reserved": 50, - "damaged": 25 - }, - "specifications": { - "battery_life": "30 hours", - "weight": "250g", - "colors": ["black", "white", "blue"], - "warranty_months": 24 - }, - "ratings": { - "average": 4.5, - "count": 1250, - "breakdown": { - "5": 750, - "4": 350, - "3": 100, - "2": 30, - "1": 20 - } - }, - "reviews": [ - { - "id": "rev_001", - "user": "john_doe", - "rating": 5, - "title": "Excellent product!", - "content": "Great sound quality and comfortable to wear.", - "helpful": 25, - "created_at": "2023-11-15T10:30:00Z" - }, - { - "id": "rev_002", - "user": "jane_smith", - "rating": 4, - "title": "Good but pricey", - "content": "Works well, could be cheaper.", - "helpful": 12, - "created_at": "2023-11-10T14:20:00Z" - } - ] - }, - "related_products": [ - { - "id": "prod_12346", - "name": "Headphone Case", - "price": 29.99 - }, - { - "id": "prod_12347", - "name": "Audio Cable", - "price": 14.99 - } - ] - }, - "request_id": "req_abc123def456", - "timestamp": "2023-11-18T22:00:00Z" - } \ No newline at end of file + "data": { + "product": { + "description": "High-quality wireless headphones with noise cancellation", + "id": "prod_12345", + "inventory": { + "available": 425, + "damaged": 25, + "reserved": 50, + "total": 500 + }, + "name": "Premium Wireless Headphones", + "price": { + "amount": 199.99, + "currency": "USD", + "discount": 10, + "final_price": 179.99 + }, + "ratings": { + "average": 4.5, + "breakdown": { + "1": 20, + "2": 30, + "3": 100, + "4": 350, + "5": 750 + }, + "count": 1250 + }, + "reviews": [ + { + "content": "Great sound quality and comfortable to wear.", + "created_at": "2023-11-15T10:30:00Z", + "helpful": 25, + "id": "rev_001", + "rating": 5, + "title": "Excellent product!", + "user": "john_doe" + }, + { + "content": "Works well, could be cheaper.", + "created_at": "2023-11-10T14:20:00Z", + "helpful": 12, + "id": "rev_002", + "rating": 4, + "title": "Good but pricey", + "user": "jane_smith" + } + ], + "sku": "PWH-001", + "specifications": { + "battery_life": "30 hours", + "colors": [ + "black", + "white", + "blue" + ], + "warranty_months": 24, + "weight": "250g" + } + }, + "related_products": [ + { + "id": "prod_12346", + "name": "Headphone Case", + "price": 29.99 + }, + { + "id": "prod_12347", + "name": "Audio Cable", + "price": 14.99 + } + ] + }, + "request_id": "req_abc123def456", + "success": true, + "timestamp": "2023-11-18T22:00:00Z" +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_simple_array.snap b/__snapshots__/test_snap_json_simple_array.snap index 4286e1c..814b55d 100644 --- a/__snapshots__/test_snap_json_simple_array.snap +++ b/__snapshots__/test_snap_json_simple_array.snap @@ -1,12 +1,12 @@ --- title: SnapJSON Simple Array test_name: TestSnapJsonSimpleArray -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- [ - "apple", - "banana", - "orange", - "grape" - ] \ No newline at end of file + "apple", + "banana", + "orange", + "grape" +] \ No newline at end of file diff --git a/__snapshots__/test_snap_json_with_nested_objects.snap b/__snapshots__/test_snap_json_with_nested_objects.snap index 35adc04..5460b3b 100644 --- a/__snapshots__/test_snap_json_with_nested_objects.snap +++ b/__snapshots__/test_snap_json_with_nested_objects.snap @@ -1,22 +1,26 @@ --- title: SnapJSON Nested Objects test_name: TestSnapJsonWithNestedObjects -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "user": { - "id": 42, - "profile": { - "username": "jane_smith", - "avatar": "https://example.com/avatar.jpg", - "settings": { - "theme": "dark", - "notifications": true, - "language": "en" - } - }, - "permissions": ["read", "write", "admin"] - }, - "created_at": "2023-06-15T10:30:00Z" - } \ No newline at end of file + "created_at": "2023-06-15T10:30:00Z", + "user": { + "id": 42, + "permissions": [ + "read", + "write", + "admin" + ], + "profile": { + "avatar": "https://example.com/avatar.jpg", + "settings": { + "language": "en", + "notifications": true, + "theme": "dark" + }, + "username": "jane_smith" + } + } +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_with_nulls.snap b/__snapshots__/test_snap_json_with_nulls.snap index b4f277b..797efc2 100644 --- a/__snapshots__/test_snap_json_with_nulls.snap +++ b/__snapshots__/test_snap_json_with_nulls.snap @@ -1,18 +1,18 @@ --- title: SnapJSON With Nulls test_name: TestSnapJsonWithNulls -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "id": 1, - "name": "Item", - "description": null, - "category": null, - "tags": null, - "metadata": { - "created": "2023-01-01", - "updated": null, - "deleted": null - } - } \ No newline at end of file + "category": null, + "description": null, + "id": 1, + "metadata": { + "created": "2023-01-01", + "deleted": null, + "updated": null + }, + "name": "Item", + "tags": null +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_with_numbers.snap b/__snapshots__/test_snap_json_with_numbers.snap index 397ac10..f12b495 100644 --- a/__snapshots__/test_snap_json_with_numbers.snap +++ b/__snapshots__/test_snap_json_with_numbers.snap @@ -1,20 +1,34 @@ --- title: SnapJSON With Numbers test_name: TestSnapJsonWithNumbers -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "integers": [0, 1, -1, 42, -100, 9999999], - "floats": [0.0, 3.14, -2.5, 0.001, 1.23e-4, 5.67e10], - "financial": { - "revenue": 1000000.50, - "expenses": 750000.75, - "profit_margin": 0.2499 - }, - "measurements": { - "temperature": -40.5, - "distance": 1000.25, - "weight": 0.5 - } - } \ No newline at end of file + "financial": { + "expenses": 750000.75, + "profit_margin": 0.2499, + "revenue": 1000000.5 + }, + "floats": [ + 0, + 3.14, + -2.5, + 0.001, + 0.000123, + 56700000000 + ], + "integers": [ + 0, + 1, + -1, + 42, + -100, + 9999999 + ], + "measurements": { + "distance": 1000.25, + "temperature": -40.5, + "weight": 0.5 + } +} \ No newline at end of file diff --git a/__snapshots__/test_snap_json_with_special_characters.snap b/__snapshots__/test_snap_json_with_special_characters.snap index 815dfac..671822c 100644 --- a/__snapshots__/test_snap_json_with_special_characters.snap +++ b/__snapshots__/test_snap_json_with_special_characters.snap @@ -1,15 +1,15 @@ --- title: SnapJSON With Special Characters test_name: TestSnapJsonWithSpecialCharacters -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- { - "special": "!@#$%^&*()_+-=[]{}|;:',.<>?/", - "escaped": "line1\nline2\ttab\rcarriage", - "quotes": "He said \"hello\" and she said 'goodbye'", - "unicode": "Hello 世界 🌍 مرحبا Привет", - "paths": "C:\\Users\\name\\Documents\\file.txt", - "html": "
Content
", - "regex": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$" - } \ No newline at end of file + "escaped": "line1\nline2\ttab\rcarriage", + "html": "\u003cdiv class=\"container\"\u003eContent\u003c/div\u003e", + "paths": "C:\\Users\\name\\Documents\\file.txt", + "quotes": "He said \"hello\" and she said 'goodbye'", + "regex": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$", + "special": "!@#$%^\u0026*()_+-=[]{}|;:',.\u003c\u003e?/", + "unicode": "Hello 世界 🌍 مرحبا Привет" +} \ No newline at end of file diff --git a/__snapshots__/test_snap_multiple.snap b/__snapshots__/test_snap_multiple.snap index c1b5120..3dcdde8 100644 --- a/__snapshots__/test_snap_multiple.snap +++ b/__snapshots__/test_snap_multiple.snap @@ -1,7 +1,7 @@ --- title: Multiple Values Test test_name: TestSnapMultiple -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- "value1" diff --git a/__snapshots__/test_snap_string.snap b/__snapshots__/test_snap_string.snap index 6f0a07e..e68f37f 100644 --- a/__snapshots__/test_snap_string.snap +++ b/__snapshots__/test_snap_string.snap @@ -1,7 +1,7 @@ --- title: Simple String Test test_name: TestSnapString -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- hello world \ No newline at end of file diff --git a/__snapshots__/test_structure_with_empty_values.snap b/__snapshots__/test_structure_with_empty_values.snap index 313f7f5..bf24822 100644 --- a/__snapshots__/test_structure_with_empty_values.snap +++ b/__snapshots__/test_structure_with_empty_values.snap @@ -1,10 +1,10 @@ --- title: Structure with Empty Values test_name: TestStructureWithEmptyValues -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- -[]freeze_test.Container{ +[]shutter_test.Container{ { Items: []string{ }, diff --git a/__snapshots__/test_structure_with_interface.snap b/__snapshots__/test_structure_with_interface.snap index 3f7150a..4c055bd 100644 --- a/__snapshots__/test_structure_with_interface.snap +++ b/__snapshots__/test_structure_with_interface.snap @@ -1,14 +1,14 @@ --- title: Structure with Interface Fields test_name: TestStructureWithInterface -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- -[]freeze_test.Response{ +[]shutter_test.Response{ { Status: "success", Message: "User retrieved", - Data: freeze_test.User{ + Data: shutter_test.User{ ID: 1, Username: "john", Email: "john@example.com", @@ -38,12 +38,12 @@ version: 0.1.0 { Status: "success", Message: "Posts retrieved", - Data: []freeze_test.Post{ + Data: []shutter_test.Post{ { ID: 1, Title: "First Post", Content: "", - Author: freeze_test.User{ + Author: shutter_test.User{ ID: 0, Username: "", Email: "", @@ -57,7 +57,7 @@ version: 0.1.0 Metadata: map[string]interface{}(nil), }, Tags: []string(nil), - Comments: []freeze_test.Comment(nil), + Comments: []shutter_test.Comment(nil), Likes: 0, Published: true, CreatedAt: time.Time{ diff --git a/__snapshots__/test_structure_with_pointers.snap b/__snapshots__/test_structure_with_pointers.snap index 5c84f67..5766ebe 100644 --- a/__snapshots__/test_structure_with_pointers.snap +++ b/__snapshots__/test_structure_with_pointers.snap @@ -1,27 +1,27 @@ --- title: Structure with Pointers test_name: TestStructureWithPointers -file_name: freeze_test.go +file_name: shutter_test.go version: 0.1.0 --- -freeze_test.Person{ +shutter_test.Person{ Name: "John", Age: 35, - Address: &freeze_test.Address{ + Address: &shutter_test.Address{ Street: "123 Main St", City: "Boston", Zip: "02101", }, - Manager: &freeze_test.Person{ + Manager: &shutter_test.Person{ Name: "Jane", Age: 30, - Address: (*freeze_test.Address)(), - Manager: (*freeze_test.Person)(nil), - Friends: []*freeze_test.Person(nil), + Address: (*shutter_test.Address)(), + Manager: (*shutter_test.Person)(nil), + Friends: []*shutter_test.Person(nil), Email: &string("jane@example.com"), }, - Friends: []*freeze_test.Person{ - (*freeze_test.Person)(), + Friends: []*shutter_test.Person{ + (*shutter_test.Person)(), }, Email: (*string)(nil), } diff --git a/api.go b/api.go index 1715b73..6903e97 100644 --- a/api.go +++ b/api.go @@ -1,9 +1,9 @@ -package freeze +package shutter import ( - "github.com/ptdewey/freeze/internal/diff" - "github.com/ptdewey/freeze/internal/files" - "github.com/ptdewey/freeze/internal/pretty" + "github.com/ptdewey/shutter/internal/diff" + "github.com/ptdewey/shutter/internal/files" + "github.com/ptdewey/shutter/internal/pretty" ) // Snapshot represents a captured test snapshot with metadata. diff --git a/cmd/freeze/main.go b/cmd/shutter/main.go similarity index 66% rename from cmd/freeze/main.go rename to cmd/shutter/main.go index 6cf3924..bc8175c 100644 --- a/cmd/freeze/main.go +++ b/cmd/shutter/main.go @@ -5,12 +5,12 @@ import ( "fmt" "os" - "github.com/ptdewey/freeze" + "github.com/ptdewey/shutter" ) func main() { flag.Usage = func() { - fmt.Fprintf(os.Stderr, `Usage: freeze [COMMAND] + fmt.Fprintf(os.Stderr, `Usage: shutter [COMMAND] Commands: review Review and accept/reject new snapshots (default) @@ -19,10 +19,10 @@ Commands: help Show this help message Examples: - freeze # Start interactive review - freeze review # Same as above - freeze accept-all # Accept all new snapshots - freeze reject-all # Reject all new snapshots + shutter # Start interactive review + shutter review # Same as above + shutter accept-all # Accept all new snapshots + shutter reject-all # Reject all new snapshots `) } @@ -36,11 +36,11 @@ Examples: var err error switch cmd { case "", "review": - err = freeze.Review() + err = shutter.Review() case "accept-all": - err = freeze.AcceptAll() + err = shutter.AcceptAll() case "reject-all": - err = freeze.RejectAll() + err = shutter.RejectAll() case "help", "-h", "--help": flag.Usage() return diff --git a/cmd/tui/go.mod b/cmd/tui/go.mod index 3c3c872..e403978 100644 --- a/cmd/tui/go.mod +++ b/cmd/tui/go.mod @@ -1,4 +1,4 @@ -module github.com/ptdewey/freeze/cmd/tui +module github.com/ptdewey/shutter/cmd/tui go 1.25.2 @@ -6,7 +6,7 @@ require ( github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/lipgloss v1.1.0 github.com/charmbracelet/bubbles v0.21.0 - github.com/ptdewey/freeze v0.0.0 + github.com/ptdewey/shutter v0.0.0 ) require ( @@ -29,4 +29,4 @@ require ( golang.org/x/text v0.3.8 // indirect ) -replace github.com/ptdewey/freeze => ../.. +replace github.com/ptdewey/shutter => ../.. diff --git a/cmd/tui/main.go b/cmd/tui/main.go index 6e46e4e..d997e22 100644 --- a/cmd/tui/main.go +++ b/cmd/tui/main.go @@ -8,9 +8,9 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/ptdewey/freeze/internal/diff" - "github.com/ptdewey/freeze/internal/files" - "github.com/ptdewey/freeze/internal/pretty" + "github.com/ptdewey/shutter/internal/diff" + "github.com/ptdewey/shutter/internal/files" + "github.com/ptdewey/shutter/internal/pretty" ) // Styles @@ -417,7 +417,7 @@ func main() { } return case "help", "-h", "--help": - fmt.Println(`Usage: freeze-tui [COMMAND] + fmt.Println(`Usage: shutter-tui [COMMAND] Commands: review Review and accept/reject new snapshots (default) diff --git a/config.go b/config.go index 9d81bca..29ccee1 100644 --- a/config.go +++ b/config.go @@ -1,4 +1,4 @@ -package freeze +package shutter // SnapshotOption is a function that configures a SnapshotConfig. type SnapshotOption func(*SnapshotConfig) diff --git a/go.mod b/go.mod index f54093e..0269636 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ptdewey/freeze +module github.com/ptdewey/shutter go 1.25.2 diff --git a/ignore.go b/ignore.go index 6c8757d..585c357 100644 --- a/ignore.go +++ b/ignore.go @@ -1,4 +1,4 @@ -package freeze +package shutter import ( "regexp" diff --git a/ignore_test.go b/ignore_test.go index a5c0a14..b7b0c74 100644 --- a/ignore_test.go +++ b/ignore_test.go @@ -1,9 +1,9 @@ -package freeze_test +package shutter_test import ( "testing" - "github.com/ptdewey/freeze" + "github.com/ptdewey/shutter" ) func TestIgnoreKeyValue(t *testing.T) { @@ -14,9 +14,9 @@ func TestIgnoreKeyValue(t *testing.T) { "api_key": "sk_live_abc123" }` - freeze.SnapJSONWithOptions(t, "Ignore Password Field", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreKeyValue("password", "*"), - freeze.IgnoreKeyValue("api_key", "*"), + shutter.SnapJSONWithOptions(t, "Ignore Password Field", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreKeyValue("password", "*"), + shutter.IgnoreKeyValue("api_key", "*"), }) } @@ -30,8 +30,8 @@ func TestIgnoreKeys(t *testing.T) { "email": "john@example.com" }` - freeze.SnapJSONWithOptions(t, "Ignore Multiple Keys", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreKeys("password", "secret", "token"), + shutter.SnapJSONWithOptions(t, "Ignore Multiple Keys", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreKeys("password", "secret", "token"), }) } @@ -46,8 +46,8 @@ func TestIgnoreSensitiveKeys(t *testing.T) { "name": "John Doe" }` - freeze.SnapJSONWithOptions(t, "Ignore Sensitive Keys", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreSensitiveKeys(), + shutter.SnapJSONWithOptions(t, "Ignore Sensitive Keys", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreSensitiveKeys(), }) } @@ -60,8 +60,8 @@ func TestIgnoreKeysMatching(t *testing.T) { "product_name": "Widget" }` - freeze.SnapJSONWithOptions(t, "Ignore Keys Matching Pattern", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreKeysMatching(`^user_`), + shutter.SnapJSONWithOptions(t, "Ignore Keys Matching Pattern", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreKeysMatching(`^user_`), }) } @@ -74,9 +74,9 @@ func TestIgnoreKeyPattern(t *testing.T) { "email": "john@example.com" }` - freeze.SnapJSONWithOptions(t, "Ignore Key Pattern", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreKeyPattern(`.*password.*`, ""), - freeze.IgnoreKeyPattern(`.*token.*`, ""), + shutter.SnapJSONWithOptions(t, "Ignore Key Pattern", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreKeyPattern(`.*password.*`, ""), + shutter.IgnoreKeyPattern(`.*token.*`, ""), }) } @@ -88,8 +88,8 @@ func TestIgnoreValues(t *testing.T) { "state": "pending" }` - freeze.SnapJSONWithOptions(t, "Ignore Specific Values", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreValues("pending"), + shutter.SnapJSONWithOptions(t, "Ignore Specific Values", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreValues("pending"), }) } @@ -102,8 +102,8 @@ func TestIgnoreEmptyValues(t *testing.T) { "phone": "" }` - freeze.SnapJSONWithOptions(t, "Ignore Empty Values", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreEmptyValues(), + shutter.SnapJSONWithOptions(t, "Ignore Empty Values", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreEmptyValues(), }) } @@ -116,8 +116,8 @@ func TestIgnoreNullValues(t *testing.T) { "age": 30 }` - freeze.SnapJSONWithOptions(t, "Ignore Null Values", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreNullValues(), + shutter.SnapJSONWithOptions(t, "Ignore Null Values", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreNullValues(), }) } @@ -130,8 +130,8 @@ func TestCustomIgnore(t *testing.T) { "grade": "A" }` - freeze.SnapJSONWithOptions(t, "Custom Ignore Function", jsonStr, []freeze.SnapshotOption{ - freeze.CustomIgnore(func(key, value string) bool { + shutter.SnapJSONWithOptions(t, "Custom Ignore Function", jsonStr, []shutter.SnapshotOption{ + shutter.CustomIgnore(func(key, value string) bool { // Ignore numeric values return value == "1" || value == "25" || value == "95" }), @@ -157,8 +157,8 @@ func TestNestedIgnorePatterns(t *testing.T) { } }` - freeze.SnapJSONWithOptions(t, "Nested Ignore Patterns", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreSensitiveKeys(), + shutter.SnapJSONWithOptions(t, "Nested Ignore Patterns", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreSensitiveKeys(), }) } @@ -173,14 +173,14 @@ func TestCombinedIgnoreAndScrub(t *testing.T) { "ip_address": "192.168.1.1" }` - freeze.SnapJSONWithOptions(t, "Combined Ignore and Scrub", jsonStr, []freeze.SnapshotOption{ + shutter.SnapJSONWithOptions(t, "Combined Ignore and Scrub", jsonStr, []shutter.SnapshotOption{ // Ignore sensitive keys entirely - freeze.IgnoreKeys("password", "api_key"), + shutter.IgnoreKeys("password", "api_key"), // Scrub dynamic/identifiable data - freeze.ScrubUUIDs(), - freeze.ScrubEmails(), - freeze.ScrubTimestamps(), - freeze.ScrubIPAddresses(), + shutter.ScrubUUIDs(), + shutter.ScrubEmails(), + shutter.ScrubTimestamps(), + shutter.ScrubIPAddresses(), }) } @@ -202,8 +202,8 @@ func TestIgnoreInArrays(t *testing.T) { ] }` - freeze.SnapJSONWithOptions(t, "Ignore in Arrays", jsonStr, []freeze.SnapshotOption{ - freeze.IgnoreKeys("password"), + shutter.SnapJSONWithOptions(t, "Ignore in Arrays", jsonStr, []shutter.SnapshotOption{ + shutter.IgnoreKeys("password"), }) } @@ -234,15 +234,15 @@ func TestComplexRealWorldExample(t *testing.T) { } }` - freeze.SnapJSONWithOptions(t, "Real World API Response", jsonStr, []freeze.SnapshotOption{ + shutter.SnapJSONWithOptions(t, "Real World API Response", jsonStr, []shutter.SnapshotOption{ // Ignore sensitive fields - freeze.IgnoreSensitiveKeys(), - freeze.IgnoreKeys("card_number"), + shutter.IgnoreSensitiveKeys(), + shutter.IgnoreKeys("card_number"), // Scrub dynamic/identifiable data - freeze.ScrubUUIDs(), - freeze.ScrubEmails(), - freeze.ScrubTimestamps(), - freeze.ScrubIPAddresses(), - freeze.ScrubJWTs(), + shutter.ScrubUUIDs(), + shutter.ScrubEmails(), + shutter.ScrubTimestamps(), + shutter.ScrubIPAddresses(), + shutter.ScrubJWTs(), }) } diff --git a/internal/diff/diff_test.go b/internal/diff/diff_test.go index 73893cd..102b4cc 100644 --- a/internal/diff/diff_test.go +++ b/internal/diff/diff_test.go @@ -3,7 +3,7 @@ package diff_test import ( "testing" - "github.com/ptdewey/freeze/internal/diff" + "github.com/ptdewey/shutter/internal/diff" ) func TestHistogramEmpty(t *testing.T) { diff --git a/internal/files/files_test.go b/internal/files/files_test.go index 7a508ed..d8137d8 100644 --- a/internal/files/files_test.go +++ b/internal/files/files_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/ptdewey/freeze/internal/files" + "github.com/ptdewey/shutter/internal/files" ) func TestSnapshotFileName(t *testing.T) { diff --git a/internal/pretty/boxes.go b/internal/pretty/boxes.go index 1eafc0b..33105bd 100644 --- a/internal/pretty/boxes.go +++ b/internal/pretty/boxes.go @@ -5,8 +5,8 @@ import ( "strconv" "strings" - "github.com/ptdewey/freeze/internal/diff" - "github.com/ptdewey/freeze/internal/files" + "github.com/ptdewey/shutter/internal/diff" + "github.com/ptdewey/shutter/internal/files" ) func NewSnapshotBox(snap *files.Snapshot) string { diff --git a/internal/pretty/pretty_test.go b/internal/pretty/pretty_test.go index 740474c..994abc2 100644 --- a/internal/pretty/pretty_test.go +++ b/internal/pretty/pretty_test.go @@ -6,9 +6,9 @@ import ( "strings" "testing" - "github.com/ptdewey/freeze/internal/diff" - "github.com/ptdewey/freeze/internal/files" - "github.com/ptdewey/freeze/internal/pretty" + "github.com/ptdewey/shutter/internal/diff" + "github.com/ptdewey/shutter/internal/files" + "github.com/ptdewey/shutter/internal/pretty" ) func TestColorFunctionsWithColor(t *testing.T) { diff --git a/internal/review/review.go b/internal/review/review.go index 02cfe1f..f68c743 100644 --- a/internal/review/review.go +++ b/internal/review/review.go @@ -6,9 +6,9 @@ import ( "os" "strings" - "github.com/ptdewey/freeze/internal/diff" - "github.com/ptdewey/freeze/internal/files" - "github.com/ptdewey/freeze/internal/pretty" + "github.com/ptdewey/shutter/internal/diff" + "github.com/ptdewey/shutter/internal/files" + "github.com/ptdewey/shutter/internal/pretty" ) type ReviewChoice int diff --git a/internal/transform/transform.go b/internal/transform/transform.go index b26556b..b671766 100644 --- a/internal/transform/transform.go +++ b/internal/transform/transform.go @@ -32,10 +32,6 @@ func ApplyScrubbers(content string, scrubbers []Scrubber) string { // TransformJSON applies scrubbers and ignore patterns to JSON data. func TransformJSON(jsonStr string, config *Config) (string, error) { - if config == nil || (len(config.Scrubbers) == 0 && len(config.Ignore) == 0) { - return jsonStr, nil - } - var data any if err := json.Unmarshal([]byte(jsonStr), &data); err != nil { return "", fmt.Errorf("failed to unmarshal JSON: %w", err) diff --git a/justfile b/justfile index 4924ed3..9a02483 100644 --- a/justfile +++ b/justfile @@ -6,14 +6,14 @@ test: @go test ./... -cover -coverprofile=cover.out run: - @go run cmd/freeze/main.go + @go run cmd/shutter/main.go clean: @rm -rf ./__snapshots__ tui: - @pushd ./cmd/tui && go build -o freeze-tui ./main.go && popd - @./cmd/tui/freeze-tui + @pushd ./cmd/tui && go build -o shutter ./main.go && popd + @./cmd/tui/shutter review: - @./cmd/tui/freeze-tui + @./cmd/tui/shutter diff --git a/scrubbers.go b/scrubbers.go index 0329e7d..654a293 100644 --- a/scrubbers.go +++ b/scrubbers.go @@ -1,4 +1,4 @@ -package freeze +package shutter import ( "regexp" @@ -106,9 +106,6 @@ func ScrubIPAddresses() SnapshotOption { }) } -// ScrubCreditCards replaces credit card numbers with "". -// Note: This uses a conservative pattern that requires context keywords to avoid -// false positives. For aggressive scrubbing, use a custom regex. func ScrubCreditCards() SnapshotOption { return WithScrubber(®exScrubber{ pattern: creditCardPattern, @@ -116,7 +113,6 @@ func ScrubCreditCards() SnapshotOption { }) } -// ScrubJWTs replaces JWT tokens with "". func ScrubJWTs() SnapshotOption { return WithScrubber(®exScrubber{ pattern: jwtPattern, @@ -124,8 +120,6 @@ func ScrubJWTs() SnapshotOption { }) } -// ScrubDates replaces dates in various formats with "". -// Matches formats like: 2023-01-15, 01/15/2023, 15-01-2023 func ScrubDates() SnapshotOption { datePattern := regexp.MustCompile(`\b\d{4}[-/]\d{2}[-/]\d{2}\b|\b\d{2}[-/]\d{2}[-/]\d{4}\b`) return WithScrubber(®exScrubber{ @@ -152,7 +146,6 @@ func (c *customScrubber) Scrub(content string) string { return c.scrubFunc(content) } -// CustomScrubber creates a scrubber using a custom function. func CustomScrubber(scrubFunc func(string) string) SnapshotOption { return WithScrubber(&customScrubber{ scrubFunc: scrubFunc, diff --git a/scrubbers_test.go b/scrubbers_test.go index 96e47bc..fb13141 100644 --- a/scrubbers_test.go +++ b/scrubbers_test.go @@ -1,10 +1,10 @@ -package freeze_test +package shutter_test import ( "strings" "testing" - "github.com/ptdewey/freeze" + "github.com/ptdewey/shutter" ) func TestScrubUUIDs(t *testing.T) { @@ -14,8 +14,8 @@ func TestScrubUUIDs(t *testing.T) { "name": "John Doe" }` - freeze.SnapJSONWithOptions(t, "Scrubbed UUIDs", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubUUIDs(), + shutter.SnapJSONWithOptions(t, "Scrubbed UUIDs", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubUUIDs(), }) } @@ -27,8 +27,8 @@ func TestScrubTimestamps(t *testing.T) { "name": "Test Event" }` - freeze.SnapJSONWithOptions(t, "Scrubbed Timestamps", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubTimestamps(), + shutter.SnapJSONWithOptions(t, "Scrubbed Timestamps", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubTimestamps(), }) } @@ -39,8 +39,8 @@ func TestScrubEmails(t *testing.T) { "name": "John Doe" }` - freeze.SnapJSONWithOptions(t, "Scrubbed Emails", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubEmails(), + shutter.SnapJSONWithOptions(t, "Scrubbed Emails", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubEmails(), }) } @@ -51,8 +51,8 @@ func TestScrubIPAddresses(t *testing.T) { "message": "Connection from 172.16.0.100" }` - freeze.SnapJSONWithOptions(t, "Scrubbed IPs", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubIPAddresses(), + shutter.SnapJSONWithOptions(t, "Scrubbed IPs", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubIPAddresses(), }) } @@ -62,8 +62,8 @@ func TestScrubJWTs(t *testing.T) { "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U" }` - freeze.SnapJSONWithOptions(t, "Scrubbed JWTs", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubJWTs(), + shutter.SnapJSONWithOptions(t, "Scrubbed JWTs", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubJWTs(), }) } @@ -76,11 +76,11 @@ func TestMultipleScrubbers(t *testing.T) { "name": "John Doe" }` - freeze.SnapJSONWithOptions(t, "Multiple Scrubbers", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubUUIDs(), - freeze.ScrubEmails(), - freeze.ScrubTimestamps(), - freeze.ScrubIPAddresses(), + shutter.SnapJSONWithOptions(t, "Multiple Scrubbers", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubUUIDs(), + shutter.ScrubEmails(), + shutter.ScrubTimestamps(), + shutter.ScrubIPAddresses(), }) } @@ -91,24 +91,24 @@ func TestRegexScrubber(t *testing.T) { "name": "Test User" }` - freeze.SnapJSONWithOptions(t, "Custom Regex Scrubber", jsonStr, []freeze.SnapshotOption{ - freeze.RegexScrubber(`sk_(live|test)_[a-zA-Z0-9]+`, ""), + shutter.SnapJSONWithOptions(t, "Custom Regex Scrubber", jsonStr, []shutter.SnapshotOption{ + shutter.RegexScrubber(`sk_(live|test)_[a-zA-Z0-9]+`, ""), }) } func TestExactMatchScrubber(t *testing.T) { content := "The secret password is 'p@ssw0rd123' and should be hidden." - freeze.SnapStringWithOptions(t, "Exact Match Scrubber", content, []freeze.SnapshotOption{ - freeze.ExactMatchScrubber("p@ssw0rd123", ""), + shutter.SnapStringWithOptions(t, "Exact Match Scrubber", content, []shutter.SnapshotOption{ + shutter.ExactMatchScrubber("p@ssw0rd123", ""), }) } func TestCustomScrubber(t *testing.T) { content := "Hello World! This is a TEST." - freeze.SnapStringWithOptions(t, "Custom Scrubber", content, []freeze.SnapshotOption{ - freeze.CustomScrubber(func(s string) string { + shutter.SnapStringWithOptions(t, "Custom Scrubber", content, []shutter.SnapshotOption{ + shutter.CustomScrubber(func(s string) string { return strings.ToLower(s) }), }) @@ -122,8 +122,8 @@ func TestScrubDates(t *testing.T) { "name": "John Doe" }` - freeze.SnapJSONWithOptions(t, "Scrubbed Dates", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubDates(), + shutter.SnapJSONWithOptions(t, "Scrubbed Dates", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubDates(), }) } @@ -135,8 +135,8 @@ func TestScrubAPIKeys(t *testing.T) { "name": "Test Config" }` - freeze.SnapJSONWithOptions(t, "Scrubbed API Keys", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubAPIKeys(), + shutter.SnapJSONWithOptions(t, "Scrubbed API Keys", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubAPIKeys(), }) } @@ -148,10 +148,10 @@ func TestScrubWithSnapFunction(t *testing.T) { "name": "John Doe", } - freeze.SnapWithOptions(t, "Scrub With Snap", []freeze.SnapshotOption{ - freeze.ScrubUUIDs(), - freeze.ScrubEmails(), - freeze.ScrubTimestamps(), + shutter.SnapWithOptions(t, "Scrub With Snap", []shutter.SnapshotOption{ + shutter.ScrubUUIDs(), + shutter.ScrubEmails(), + shutter.ScrubTimestamps(), }, data) } @@ -163,8 +163,8 @@ func TestCreditCardScrubbing(t *testing.T) { "name": "John Doe" }` - freeze.SnapJSONWithOptions(t, "Scrubbed Credit Cards", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubCreditCards(), + shutter.SnapJSONWithOptions(t, "Scrubbed Credit Cards", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubCreditCards(), }) } @@ -176,7 +176,7 @@ func TestUnixTimestampScrubbing(t *testing.T) { "name": "Test Event" }` - freeze.SnapJSONWithOptions(t, "Scrubbed Unix Timestamps", jsonStr, []freeze.SnapshotOption{ - freeze.ScrubUnixTimestamps(), + shutter.SnapJSONWithOptions(t, "Scrubbed Unix Timestamps", jsonStr, []shutter.SnapshotOption{ + shutter.ScrubUnixTimestamps(), }) } diff --git a/freeze.go b/shutter.go similarity index 88% rename from freeze.go rename to shutter.go index 0a50fa0..280c3ab 100644 --- a/freeze.go +++ b/shutter.go @@ -1,4 +1,4 @@ -package freeze +package shutter import ( "fmt" @@ -6,11 +6,11 @@ import ( "runtime" "github.com/kortschak/utter" - "github.com/ptdewey/freeze/internal/diff" - "github.com/ptdewey/freeze/internal/files" - "github.com/ptdewey/freeze/internal/pretty" - "github.com/ptdewey/freeze/internal/review" - "github.com/ptdewey/freeze/internal/transform" + "github.com/ptdewey/shutter/internal/diff" + "github.com/ptdewey/shutter/internal/files" + "github.com/ptdewey/shutter/internal/pretty" + "github.com/ptdewey/shutter/internal/review" + "github.com/ptdewey/shutter/internal/transform" ) const version = "0.1.0" @@ -94,7 +94,7 @@ func snap(t testingT, title string, content string) { testName := t.Name() // Capture the caller's file name by walking up the call stack - // to find the first file that's not freeze.go TODO: does this actually work for all cases? + // to find the first file that's not shutter.go TODO: does this actually work for all cases? fileName := "unknown" for i := 1; i < 10; i++ { _, file, _, ok := runtime.Caller(i) @@ -102,8 +102,8 @@ func snap(t testingT, title string, content string) { break } baseName := filepath.Base(file) - // Skip frames within freeze.go to get to the actual test file - if baseName != "freeze.go" { + // Skip frames within shutter.go to get to the actual test file + if baseName != "shutter.go" { fileName = baseName break } @@ -136,7 +136,7 @@ func snapWithTitle(t testingT, title string, testName string, fileName string, c diffLines := diff.Histogram(accepted.Content, snapshot.Content) fmt.Println(pretty.DiffSnapshotBox(accepted, snapshot, diffLines)) - t.Error("snapshot mismatch - run 'freeze review' to update") + t.Error("snapshot mismatch - run 'shutter review' to update") return } @@ -146,7 +146,7 @@ func snapWithTitle(t testingT, title string, testName string, fileName string, c } fmt.Println(pretty.NewSnapshotBox(snapshot)) - t.Error("new snapshot created - run 'freeze review' to accept") + t.Error("new snapshot created - run 'shutter review' to accept") } func formatValues(values ...any) string { @@ -187,7 +187,7 @@ type testingT interface { Cleanup(func()) } -// Type conversion helpers to bridge freeze package types with transform package types. +// Type conversion helpers to bridge shutter package types with transform package types. // These work because the interfaces have identical method signatures (structural typing). func toTransformScrubbers(scrubbers []Scrubber) []transform.Scrubber { diff --git a/freeze_test.go b/shutter_test.go similarity index 90% rename from freeze_test.go rename to shutter_test.go index fa896f9..bd7bfcc 100644 --- a/freeze_test.go +++ b/shutter_test.go @@ -1,4 +1,4 @@ -package freeze_test +package shutter_test import ( "encoding/json" @@ -9,16 +9,16 @@ import ( "testing" "time" - "github.com/ptdewey/freeze" - "github.com/ptdewey/freeze/internal/files" + "github.com/ptdewey/shutter" + "github.com/ptdewey/shutter/internal/files" ) func TestSnapString(t *testing.T) { - freeze.SnapString(t, "Simple String Test", "hello world") + shutter.SnapString(t, "Simple String Test", "hello world") } func TestSnapMultiple(t *testing.T) { - freeze.Snap(t, "Multiple Values Test", "value1", "value2", 42, "foo", "bar", "baz", "wibble", "wobble", "tock", nil) + shutter.Snap(t, "Multiple Values Test", "value1", "value2", 42, "foo", "bar", "baz", "wibble", "wobble", "tock", nil) } type CustomStruct struct { @@ -35,18 +35,18 @@ func TestSnapCustomType(t *testing.T) { Name: "Alice", Age: 30, } - freeze.Snap(t, "Custom Type Test", cs) + shutter.Snap(t, "Custom Type Test", cs) } func TestMap(t *testing.T) { - freeze.Snap(t, "Map Test", map[string]any{ + shutter.Snap(t, "Map Test", map[string]any{ "foo": "bar", "wibble": "wobble", }) } func TestSerializeDeserialize(t *testing.T) { - snap := &freeze.Snapshot{ + snap := &shutter.Snapshot{ Title: "My Test Title", Test: "TestExample", FileName: "test_file.go", @@ -59,7 +59,7 @@ func TestSerializeDeserialize(t *testing.T) { t.Errorf("expected:\n%s\ngot:\n%s", expected, serialized) } - deserialized, err := freeze.Deserialize(serialized) + deserialized, err := shutter.Deserialize(serialized) if err != nil { t.Fatalf("failed to deserialize: %v", err) } @@ -79,7 +79,7 @@ func TestSerializeDeserialize(t *testing.T) { } func TestFileOperations(t *testing.T) { - snap := &freeze.Snapshot{ + snap := &shutter.Snapshot{ Title: "File Ops Title", Test: "TestFileOps", Content: "file test content", @@ -89,7 +89,7 @@ func TestFileOperations(t *testing.T) { t.Fatalf("failed to save snapshot: %v", err) } - read, err := freeze.ReadSnapshot("TestFileOps", "test") + read, err := shutter.ReadSnapshot("TestFileOps", "test") if err != nil { t.Fatalf("failed to read snapshot: %v", err) } @@ -113,7 +113,7 @@ func TestSnapshotFileName(t *testing.T) { } for _, tt := range tests { - result := freeze.SnapshotFileName(tt.input) + result := shutter.SnapshotFileName(tt.input) if result != tt.expected { t.Errorf("SnapshotFileName(%s) = %s, want %s", tt.input, result, tt.expected) } @@ -124,13 +124,13 @@ func TestHistogramDiff(t *testing.T) { oldStr := "line1\nline2\nline3" newStr := "line1\nmodified\nline3" - diff := freeze.Histogram(oldStr, newStr) + diff := shutter.Histogram(oldStr, newStr) if len(diff) < 3 { t.Errorf("expected at least 3 diff lines, got %d", len(diff)) } - if diff[0].Kind != freeze.DiffShared || diff[0].Line != "line1" { + if diff[0].Kind != shutter.DiffShared || diff[0].Line != "line1" { t.Errorf("line 0: expected shared 'line1', got %v %s", diff[0].Kind, diff[0].Line) } @@ -138,7 +138,7 @@ func TestHistogramDiff(t *testing.T) { for _, d := range diff { if d.Line == "modified" { hasModified = true - if d.Kind != freeze.DiffNew { + if d.Kind != shutter.DiffNew { t.Errorf("'modified' should be marked as new") } } @@ -149,7 +149,7 @@ func TestHistogramDiff(t *testing.T) { hasLine3 := false for _, d := range diff { - if d.Line == "line3" && d.Kind == freeze.DiffShared { + if d.Line == "line3" && d.Kind == shutter.DiffShared { hasLine3 = true } } @@ -159,19 +159,19 @@ func TestHistogramDiff(t *testing.T) { } func TestDiffSnapshotBox(t *testing.T) { - old := &freeze.Snapshot{ + old := &shutter.Snapshot{ Title: "Diff Test Title", Test: "TestDiff", Content: "old content", } - new := &freeze.Snapshot{ + new := &shutter.Snapshot{ Title: "Diff Test Title", Test: "TestDiff", Content: "new content", } - box := freeze.DiffSnapshotBox(old, new) + box := shutter.DiffSnapshotBox(old, new) if box == "" { t.Error("DiffSnapshotBox returned empty string") } @@ -182,13 +182,13 @@ func TestDiffSnapshotBox(t *testing.T) { } func TestNewSnapshotBox(t *testing.T) { - snap := &freeze.Snapshot{ + snap := &shutter.Snapshot{ Title: "New Test Title", Test: "TestNew", Content: "test content", } - box := freeze.NewSnapshotBox(snap) + box := shutter.NewSnapshotBox(snap) if box == "" { t.Error("NewSnapshotBox returned empty string") } @@ -305,7 +305,7 @@ func TestComplexNestedStructure(t *testing.T) { CreatedAt: time.Date(2023, 1, 20, 9, 0, 0, 0, time.UTC), } - freeze.Snap(t, "Complex Nested Structure", post) + shutter.Snap(t, "Complex Nested Structure", post) } func TestMultipleComplexStructures(t *testing.T) { @@ -345,7 +345,7 @@ func TestMultipleComplexStructures(t *testing.T) { }, } - freeze.Snap(t, "Multiple Complex Structures", users) + shutter.Snap(t, "Multiple Complex Structures", users) } func TestStructureWithInterface(t *testing.T) { @@ -398,7 +398,7 @@ func TestStructureWithInterface(t *testing.T) { }, } - freeze.Snap(t, "Structure with Interface Fields", responses) + shutter.Snap(t, "Structure with Interface Fields", responses) } func TestNestedMapsAndSlices(t *testing.T) { @@ -444,7 +444,7 @@ func TestNestedMapsAndSlices(t *testing.T) { }, } - freeze.Snap(t, "Nested Maps and Slices", complexData) + shutter.Snap(t, "Nested Maps and Slices", complexData) } func TestStructureWithPointers(t *testing.T) { @@ -486,7 +486,7 @@ func TestStructureWithPointers(t *testing.T) { Friends: []*Person{&person1}, } - freeze.Snap(t, "Structure with Pointers", person2) + shutter.Snap(t, "Structure with Pointers", person2) } func TestStructureWithEmptyValues(t *testing.T) { @@ -522,7 +522,7 @@ func TestStructureWithEmptyValues(t *testing.T) { }, } - freeze.Snap(t, "Structure with Empty Values", containers) + shutter.Snap(t, "Structure with Empty Values", containers) } // ============================================================================ @@ -553,7 +553,7 @@ func TestJsonObject(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "JSON Object", data) + shutter.Snap(t, "JSON Object", data) } func TestComplexJsonStructure(t *testing.T) { @@ -621,7 +621,7 @@ func TestComplexJsonStructure(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "Complex JSON Structure", data) + shutter.Snap(t, "Complex JSON Structure", data) } func TestJsonArrayOfObjects(t *testing.T) { @@ -659,7 +659,7 @@ func TestJsonArrayOfObjects(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "JSON Array of Objects", data) + shutter.Snap(t, "JSON Array of Objects", data) } func TestJsonWithVariousTypes(t *testing.T) { @@ -685,7 +685,7 @@ func TestJsonWithVariousTypes(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "JSON with Various Types", data) + shutter.Snap(t, "JSON with Various Types", data) } func TestJsonNumbers(t *testing.T) { @@ -713,7 +713,7 @@ func TestJsonNumbers(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "JSON Numbers", data) + shutter.Snap(t, "JSON Numbers", data) } func TestJsonWithSpecialCharacters(t *testing.T) { @@ -733,7 +733,7 @@ func TestJsonWithSpecialCharacters(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "JSON with Special Characters", data) + shutter.Snap(t, "JSON with Special Characters", data) } func TestGoStructMarshalledToJson(t *testing.T) { @@ -777,7 +777,7 @@ func TestGoStructMarshalledToJson(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "Go Struct Marshalled to JSON", data) + shutter.Snap(t, "Go Struct Marshalled to JSON", data) } func TestDeeplyNestedJson(t *testing.T) { @@ -817,7 +817,7 @@ func TestDeeplyNestedJson(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "Deeply Nested JSON", data) + shutter.Snap(t, "Deeply Nested JSON", data) } func TestLargeJson(t *testing.T) { @@ -893,7 +893,7 @@ func TestLargeJson(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "Large JSON Structure", data) + shutter.Snap(t, "Large JSON Structure", data) } func TestJsonWithMixedArrays(t *testing.T) { @@ -924,7 +924,7 @@ func TestJsonWithMixedArrays(t *testing.T) { t.Fatalf("failed to unmarshal json: %v", err) } - freeze.Snap(t, "JSON with Mixed Arrays", data) + shutter.Snap(t, "JSON with Mixed Arrays", data) } // ============================================================================ @@ -939,7 +939,7 @@ func TestSnapJsonBasic(t *testing.T) { "verified": true }` - freeze.SnapJSON(t, "SnapJSON Basic Object", jsonStr) + shutter.SnapJSON(t, "SnapJSON Basic Object", jsonStr) } func TestSnapJsonSimpleArray(t *testing.T) { @@ -950,13 +950,13 @@ func TestSnapJsonSimpleArray(t *testing.T) { "grape" ]` - freeze.SnapJSON(t, "SnapJSON Simple Array", jsonStr) + shutter.SnapJSON(t, "SnapJSON Simple Array", jsonStr) } func TestSnapJsonCompactFormat(t *testing.T) { jsonStr := `{"id":1,"name":"Product","price":99.99,"in_stock":true,"tags":["electronics","gadgets"]}` - freeze.SnapJSON(t, "SnapJSON Compact Format", jsonStr) + shutter.SnapJSON(t, "SnapJSON Compact Format", jsonStr) } func TestSnapJsonWithNestedObjects(t *testing.T) { @@ -977,7 +977,7 @@ func TestSnapJsonWithNestedObjects(t *testing.T) { "created_at": "2023-06-15T10:30:00Z" }` - freeze.SnapJSON(t, "SnapJSON Nested Objects", jsonStr) + shutter.SnapJSON(t, "SnapJSON Nested Objects", jsonStr) } func TestSnapJsonComplexAPI(t *testing.T) { @@ -1018,7 +1018,7 @@ func TestSnapJsonComplexAPI(t *testing.T) { "timestamp": "2023-11-18T21:45:30Z" }` - freeze.SnapJSON(t, "SnapJSON Complex API Response", jsonStr) + shutter.SnapJSON(t, "SnapJSON Complex API Response", jsonStr) } func TestSnapJsonWithNulls(t *testing.T) { @@ -1035,7 +1035,7 @@ func TestSnapJsonWithNulls(t *testing.T) { } }` - freeze.SnapJSON(t, "SnapJSON With Nulls", jsonStr) + shutter.SnapJSON(t, "SnapJSON With Nulls", jsonStr) } func TestSnapJsonArrayOfObjects(t *testing.T) { @@ -1063,7 +1063,7 @@ func TestSnapJsonArrayOfObjects(t *testing.T) { } ]` - freeze.SnapJSON(t, "SnapJSON Array of Objects", jsonStr) + shutter.SnapJSON(t, "SnapJSON Array of Objects", jsonStr) } func TestSnapJsonLargeNestedStructure(t *testing.T) { @@ -1125,7 +1125,7 @@ func TestSnapJsonLargeNestedStructure(t *testing.T) { } }` - freeze.SnapJSON(t, "SnapJSON Large Nested Structure", jsonStr) + shutter.SnapJSON(t, "SnapJSON Large Nested Structure", jsonStr) } func TestSnapJsonWithNumbers(t *testing.T) { @@ -1144,7 +1144,7 @@ func TestSnapJsonWithNumbers(t *testing.T) { } }` - freeze.SnapJSON(t, "SnapJSON With Numbers", jsonStr) + shutter.SnapJSON(t, "SnapJSON With Numbers", jsonStr) } func TestSnapJsonWithSpecialCharacters(t *testing.T) { @@ -1158,7 +1158,7 @@ func TestSnapJsonWithSpecialCharacters(t *testing.T) { "regex": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$" }` - freeze.SnapJSON(t, "SnapJSON With Special Characters", jsonStr) + shutter.SnapJSON(t, "SnapJSON With Special Characters", jsonStr) } func TestSnapJsonEmptyStructures(t *testing.T) { @@ -1175,7 +1175,7 @@ func TestSnapJsonEmptyStructures(t *testing.T) { } }` - freeze.SnapJSON(t, "SnapJSON Empty Structures", jsonStr) + shutter.SnapJSON(t, "SnapJSON Empty Structures", jsonStr) } func TestSnapJsonMixedTypes(t *testing.T) { @@ -1199,7 +1199,7 @@ func TestSnapJsonMixedTypes(t *testing.T) { ] }` - freeze.SnapJSON(t, "SnapJSON Mixed Types", jsonStr) + shutter.SnapJSON(t, "SnapJSON Mixed Types", jsonStr) } func TestSnapJsonRealWorldExample(t *testing.T) { @@ -1278,7 +1278,7 @@ func TestSnapJsonRealWorldExample(t *testing.T) { "timestamp": "2023-11-18T22:00:00Z" }` - freeze.SnapJSON(t, "SnapJSON Real World Example", jsonStr) + shutter.SnapJSON(t, "SnapJSON Real World Example", jsonStr) } func ptr[T any](t T) *T { return &t }