diff --git a/internal/adapters/weatherapi/client.go b/internal/adapters/weatherapi/client.go index 7540c0f..09fb548 100644 --- a/internal/adapters/weatherapi/client.go +++ b/internal/adapters/weatherapi/client.go @@ -19,7 +19,6 @@ import ( "time" "gitea.maximumdirect.net/eric/weatherreporter/internal/config" - "gitea.maximumdirect.net/eric/weatherreporter/internal/fileutil" "gitea.maximumdirect.net/eric/weatherreporter/internal/weatherdata" ) @@ -718,10 +717,3 @@ func sourceHash(raw json.RawMessage) (string, error) { sum := sha256.Sum256(compact.Bytes()) return hex.EncodeToString(sum[:]), nil } - -func SaveBundle(path string, bundle *weatherdata.Bundle) error { - if err := fileutil.WriteJSONAtomic(path, bundle); err != nil { - return fmt.Errorf("save bundle: %w", err) - } - return nil -} diff --git a/internal/adapters/weatherapi/client_test.go b/internal/adapters/weatherapi/client_test.go index eeea722..1d090ab 100644 --- a/internal/adapters/weatherapi/client_test.go +++ b/internal/adapters/weatherapi/client_test.go @@ -1055,27 +1055,6 @@ func TestHTTPTimeout(t *testing.T) { } } -func TestSaveBundle(t *testing.T) { - server := fixtureServer(t, nil, nil) - client := newTestClient(t, server.URL+"/", nil) - bundle, err := client.FetchBundle(context.Background()) - if err != nil { - t.Fatalf("FetchBundle() error = %v", err) - } - - path := filepath.Join(t.TempDir(), "nested", "bundle.json") - if err := SaveBundle(path, bundle); err != nil { - t.Fatalf("SaveBundle() error = %v", err) - } - data, err := os.ReadFile(path) - if err != nil { - t.Fatalf("read saved bundle: %v", err) - } - if !strings.Contains(string(data), `"hourly"`) { - t.Fatalf("saved bundle missing hourly source:\n%s", string(data)) - } -} - type handlerOverride struct { status int body string diff --git a/internal/fileutil/fileutil.go b/internal/fileutil/fileutil.go index 91161ae..ee2282e 100644 --- a/internal/fileutil/fileutil.go +++ b/internal/fileutil/fileutil.go @@ -3,7 +3,6 @@ package fileutil import ( "context" - "encoding/json" "fmt" "os" "path/filepath" @@ -74,11 +73,3 @@ func WriteFileAtomicContext(ctx context.Context, path string, data []byte) error } return nil } - -func WriteJSONAtomic(path string, value any) error { - data, err := json.MarshalIndent(value, "", " ") - if err != nil { - return fmt.Errorf("marshal %q: %w", path, err) - } - return WriteFileAtomic(path, data) -} diff --git a/internal/fileutil/fileutil_test.go b/internal/fileutil/fileutil_test.go index 3288f59..0b30465 100644 --- a/internal/fileutil/fileutil_test.go +++ b/internal/fileutil/fileutil_test.go @@ -150,19 +150,3 @@ func TestWriteFileAtomicContextPreservesDestinationWhenCanceledAtPublication(t * t.Fatalf("temporary files/error = %v/%v", matches, globErr) } } - -func TestWriteJSONAtomic(t *testing.T) { - path := filepath.Join(t.TempDir(), "artifact.json") - - if err := WriteJSONAtomic(path, map[string]string{"status": "ok"}); err != nil { - t.Fatalf("WriteJSONAtomic() error = %v", err) - } - - data, err := os.ReadFile(path) - if err != nil { - t.Fatalf("ReadFile() error = %v", err) - } - if string(data) != "{\n \"status\": \"ok\"\n}" { - t.Fatalf("json = %q, want indented object", data) - } -}