Skip to content

Commit

Permalink
add more tests and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
fraidev committed Nov 17, 2023
1 parent 80687ad commit 86c880f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/photographer/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ func getSnapshotName(historyMode snapshot.HistoryModeType) (string, error) {
}

func getSnapshotHeaderOutput(filepath string) string {
log.Printf("Getting snapshot header output for file: %q. \n", filepath)
script := "/usr/local/bin/octez-node snapshot info --json" + filepath
stdout, _ := execScript(script)
log.Printf("Snapshot header output: %q. \n", stdout.String())
return stdout.String()
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/photographer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ func execute(ctx context.Context, snapshotStorage *store.SnapshotStorage, histor

createSnapshot(historyMode)
snapshotfilename, err := getSnapshotName(historyMode)
snapshotHeaderOutput := getSnapshotHeaderOutput(snapshotfilename)

if err != nil {
log.Fatalf("%v \n", err)
}
snapshotHeaderOutput := getSnapshotHeaderOutput(snapshotfilename)

snapshotStorage.EphemeralUpload(ctx, snapshotfilename, snapshotHeaderOutput)
}
39 changes: 39 additions & 0 deletions pkg/store/fileinfo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package store

import (
"testing"
)

func Test_fileinfo(t *testing.T) {
tests := []struct {
name string
args []string
want []string
}{
{
name: "Test_fileinfo",
args: []string{
"TEZOS_HANGZHOUNET_2022-01-22T15:00:00Z-BKpkmdGCx8D9KAUAYJrrrmFqgamcwZWFYo2W4KiyEP4PCBJQrsC-589926.full",
"TEZOS_ITHACANET_2022-01-22T15:00:00Z-BKpkmdGCx8D9KAUAYJrrrmFqgamcwZWFYo2W4KiyEP4PCBJQrsC-589926.rolling",
"TEZOS_MAINNET-BL4p3YRfxhiQP16PsuzFBbph8QqVcNN3qu42r5JgNgdaw3xW81g-2396664.rolling",
"TEZOS_MAINNET-BMBDsvNoA4wr4VANmUJfMPPEpCKKBYY7xBoYfhJkUuoGk54GYPa-4593763.rolling",
},
want: []string{
"hangzhounet",
"ghostnet",
"mainnet",
"mainnet",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for i, want := range tt.want {
got := getInfoFromfilename(tt.args[i])
if got.ChainName != want {
t.Errorf("got: %v, want: %v", got, want)
}
}
})
}
}

0 comments on commit 86c880f

Please sign in to comment.