Skip to content

Commit

Permalink
Add invalid datetime save test
Browse files Browse the repository at this point in the history
  • Loading branch information
seanavery committed Sep 9, 2024
1 parent 4e8d545 commit e7909ee
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,30 @@ func TestSaveDoCommand(t *testing.T) {
]
}`, videoStoreComponentName, testUploadPath, storagePath, moduleBinPath)

// Valid time range
saveCmd1 := map[string]interface{}{
"command": "save",
"from": "2024-09-06_15-00-33",
"to": "2024-09-06_15-01-33",
"metadata": "test-metadata",
}

// Invalid time range
saveCmd2 := map[string]interface{}{
"command": "save",
"from": "2024-09-06_14-00-03",
"to": "2024-09-06_15-01-33",
"metadata": "test-metadata",
}

// Invalid datetime format
saveCmd3 := map[string]interface{}{
"command": "save",
"from": "2024-09-06_15-00-33",
"to": "2024/09/06 15:01:33",
"metadata": "test-metadata",
}

t.Run("Test Save DoCommand Valid Range", func(t *testing.T) {
timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
Expand Down Expand Up @@ -144,4 +154,22 @@ func TestSaveDoCommand(t *testing.T) {
t.Fatalf("expected error for invalid time range")
}
})

t.Run("Test Save DoCommand Invalid Datetime Format", func(t *testing.T) {
timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
r, err := setupViamServer(timeoutCtx, config1)
if err != nil {
t.Fatalf("failed to setup viam server: %v", err)
}
defer r.Close(timeoutCtx)
vs, err := camera.FromRobot(r, videoStoreComponentName)
if err != nil {
t.Fatalf("failed to get video store component: %v", err)
}
_, err = vs.DoCommand(timeoutCtx, saveCmd3)
if err == nil {
t.Fatalf("expected error for invalid datetime format")
}
})
}

0 comments on commit e7909ee

Please sign in to comment.