Skip to content

Commit

Permalink
fix(fmannotator): tests related to updated current state logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalenic committed Oct 13, 2024
1 parent 1e46827 commit a7b6b79
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/workload/stateless/stacks/fmannotator/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func PortalRunId(event workflowrunstatechange.Event, config *Config, token strin
}

req = req.WithMethod("PATCH").WithS3Endpoint().WithQuery(url.Values{
"key": {fmt.Sprintf("*/%v/*", event.Detail.PortalRunId)},
"currentState": {"false"},
"key": {fmt.Sprintf("*/%v/*", event.Detail.PortalRunId)},
}).WithHeader("Content-Type", "application/json").WithHeader("Authorization", fmt.Sprintf("Bearer %s", token))

body, status, err := req.Do()
Expand Down
6 changes: 6 additions & 0 deletions lib/workload/stateless/stacks/fmannotator/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fmannotator

import (
"database/sql"
"encoding/json"
"fmt"
_ "github.com/lib/pq"
"github.com/stretchr/testify/require"
Expand All @@ -26,6 +27,7 @@ func successCase(location *time.Location) TestCase {
EventTime: sql.NullTime{Time: time.Date(2024, 9, 2, 0, 0, 0, 0, location), Valid: true},
Size: sql.NullInt64{Int64: 5, Valid: true},
StorageClass: sql.NullString{String: "Standard", Valid: true},
Attributes: json.RawMessage(`{"portalRunId": "202409021221e6e6"}`),
},
{
EventType: "Deleted",
Expand All @@ -34,6 +36,7 @@ func successCase(location *time.Location) TestCase {
EventTime: sql.NullTime{Time: time.Date(2024, 9, 3, 0, 0, 0, 0, location), Valid: true},
Size: sql.NullInt64{},
StorageClass: sql.NullString{},
Attributes: json.RawMessage(`{"portalRunId": "202409021221e6e6"}`),
},
{
EventType: "Created",
Expand All @@ -42,6 +45,7 @@ func successCase(location *time.Location) TestCase {
EventTime: sql.NullTime{Time: time.Date(2024, 9, 4, 0, 0, 0, 0, location), Valid: true},
Size: sql.NullInt64{Int64: 10, Valid: true},
StorageClass: sql.NullString{String: "Standard", Valid: true},
Attributes: json.RawMessage(`{"portalRunId": "202409021221e6e6"}`),
},
}}
}
Expand All @@ -55,6 +59,7 @@ func failCase(location *time.Location) TestCase {
EventTime: sql.NullTime{Time: time.Date(2024, 9, 5, 0, 0, 0, 0, location), Valid: true},
Size: sql.NullInt64{Int64: 3, Valid: true},
StorageClass: sql.NullString{String: "Standard", Valid: true},
Attributes: json.RawMessage(`{"portalRunId": "202409021221e6c6"}`),
},
{
EventType: "Deleted",
Expand All @@ -63,6 +68,7 @@ func failCase(location *time.Location) TestCase {
EventTime: sql.NullTime{Time: time.Date(2024, 9, 6, 0, 0, 0, 0, location), Valid: true},
Size: sql.NullInt64{},
StorageClass: sql.NullString{},
Attributes: json.RawMessage(`{"portalRunId": "202409021221e6c6"}`),
},
}}
}
Expand Down
13 changes: 7 additions & 6 deletions lib/workload/stateless/stacks/fmannotator/internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (

// S3Object Represents a mock S3Object.
type S3Object struct {
EventType string `db:"event_type"`
Bucket string `db:"bucket"`
Key string `db:"key"`
EventTime sql.NullTime `db:"event_time"`
Size sql.NullInt64 `db:"size"`
StorageClass sql.NullString `db:"storage_class"`
EventType string `db:"event_type"`
Bucket string `db:"bucket"`
Key string `db:"key"`
EventTime sql.NullTime `db:"event_time"`
Size sql.NullInt64 `db:"size"`
StorageClass sql.NullString `db:"storage_class"`
Attributes json.RawMessage `db:"attributes"`
}

// SetupFileManager Setup the filemanager for testing.
Expand Down

0 comments on commit a7b6b79

Please sign in to comment.