package bundle_test import ( "fmt" "os" "path/filepath" "time" "gitea.maximumdirect.net/eric/distributor/pkg/bundle" ) func ExampleBuildManifest() { root, err := os.MkdirTemp("", "distributor-bundle-*") if err != nil { panic(err) } defer os.RemoveAll(root) if err := os.WriteFile(filepath.Join(root, "report.txt"), []byte("report\n"), 0o600); err != nil { panic(err) } manifest, err := bundle.BuildManifest(bundle.BuildOptions{ Root: root, ID: "reports.example", Created: time.Date(2026, 5, 30, 11, 10, 0, 0, time.UTC), Files: []string{"report.txt"}, }) if err != nil { panic(err) } fmt.Println(manifest.ID) fmt.Println(manifest.Files[0].Path) fmt.Println(manifest.Files[0].Size) // Output: // reports.example // report.txt // 7 } func ExampleWriteBundle() { sourceRoot, err := os.MkdirTemp("", "distributor-source-*") if err != nil { panic(err) } defer os.RemoveAll(sourceRoot) outputRoot := filepath.Join(os.TempDir(), "distributor-bundle-example") defer os.RemoveAll(outputRoot) if err := os.WriteFile(filepath.Join(sourceRoot, "report.txt"), []byte("report\n"), 0o600); err != nil { panic(err) } manifest, err := bundle.WriteBundle(bundle.WriteBundleOptions{ Root: outputRoot, ID: "reports.example", Created: time.Date(2026, 5, 30, 11, 10, 0, 0, time.UTC), Files: []bundle.BundleFile{ {SourcePath: filepath.Join(sourceRoot, "report.txt"), Path: "report.txt"}, }, Overwrite: true, }) if err != nil { panic(err) } fmt.Println(manifest.ID) fmt.Println(manifest.Files[0].Path) // Output: // reports.example // report.txt }