Skip to content

Commit 168591b

Browse files
fix: consistent oapi time formatting for env created_at
1 parent 66f7186 commit 168591b

File tree

13 files changed

+29
-30
lines changed

13 files changed

+29
-30
lines changed

apps/workspace-engine/oapi/openapi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@
569569
"Environment": {
570570
"properties": {
571571
"createdAt": {
572+
"format": "date-time",
572573
"type": "string"
573574
},
574575
"description": {

apps/workspace-engine/oapi/spec/schemas/entities.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ local openapi = import '../lib/openapi.libsonnet';
7171
description: { type: 'string' },
7272
systemId: { type: 'string' },
7373
resourceSelector: openapi.schemaRef('Selector'),
74-
createdAt: { type: 'string' },
74+
createdAt: { type: 'string', format: 'date-time' },
7575
},
7676
},
7777

apps/workspace-engine/pkg/db/environments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func getEnvironments(ctx context.Context, workspaceID string) ([]*oapi.Environme
5252
if err != nil {
5353
return nil, err
5454
}
55-
environment.CreatedAt = createdAt.Format(time.RFC3339)
55+
environment.CreatedAt = createdAt
5656

5757
// Wrap selector from unwrapped database format to JsonSelector format
5858
environment.ResourceSelector, err = wrapSelectorFromDB(rawSelector)

apps/workspace-engine/pkg/db/environments_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func validateRetrievedEnvironments(t *testing.T, actualEnvironments []*oapi.Envi
4141
if (actualEnv.ResourceSelector == nil) != (expectedEnv.ResourceSelector == nil) {
4242
t.Fatalf("resource_selector nil mismatch: expected %v, got %v", expectedEnv.ResourceSelector == nil, actualEnv.ResourceSelector == nil)
4343
}
44-
if actualEnv.CreatedAt == "" {
44+
if actualEnv.CreatedAt.IsZero() {
4545
t.Fatalf("expected environment created_at to be set")
4646
}
4747
}

apps/workspace-engine/pkg/db/persistence/store_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ func TestStore_SaveAndLoad_OAPIEnvironment(t *testing.T) {
11791179
Id: uuid.New().String(),
11801180
Name: "production",
11811181
SystemId: uuid.New().String(),
1182-
CreatedAt: time.Now().Format(time.RFC3339),
1182+
CreatedAt: time.Now(),
11831183
}
11841184

11851185
changes := persistence.Changes{
@@ -1412,7 +1412,7 @@ func TestStore_SaveAndLoad_AllOAPIEntityTypes(t *testing.T) {
14121412
Id: uuid.New().String(),
14131413
Name: "Environment 1",
14141414
SystemId: uuid.New().String(),
1415-
CreatedAt: time.Now().Format(time.RFC3339),
1415+
CreatedAt: time.Now(),
14161416
}
14171417

14181418
system := &oapi.System{

apps/workspace-engine/pkg/events/handler/resources/resourceproviders_bench_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func createTestResource(workspaceID, resourceID, identifier, name string) *oapi.
3636

3737
// createTestEnvironment creates a test environment with the given ID and system
3838
func createTestEnvironment(systemID, environmentID, name string) *oapi.Environment {
39-
now := time.Now().Format(time.RFC3339)
4039
selector := &oapi.Selector{}
4140
// Create a selector that matches all resources (name starts with empty string)
4241
_ = selector.FromJsonSelector(oapi.JsonSelector{
@@ -54,7 +53,7 @@ func createTestEnvironment(systemID, environmentID, name string) *oapi.Environme
5453
Description: &description,
5554
SystemId: systemID,
5655
ResourceSelector: selector,
57-
CreatedAt: now,
56+
CreatedAt: time.Now(),
5857
}
5958
}
6059

apps/workspace-engine/pkg/oapi/oapi.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/workspace-engine/pkg/selector/match_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func TestMatch_JsonSelector_Environment(t *testing.T) {
398398
Id: "1",
399399
Name: "production",
400400
SystemId: "sys1",
401-
CreatedAt: "2024-01-01T00:00:00Z",
401+
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
402402
},
403403
wantMatch: true,
404404
wantErr: false,
@@ -414,7 +414,7 @@ func TestMatch_JsonSelector_Environment(t *testing.T) {
414414
Id: "2",
415415
Name: "staging",
416416
SystemId: "sys1",
417-
CreatedAt: "2024-01-01T00:00:00Z",
417+
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
418418
},
419419
wantMatch: false,
420420
wantErr: false,
@@ -430,7 +430,7 @@ func TestMatch_JsonSelector_Environment(t *testing.T) {
430430
Id: "3",
431431
Name: "production-us-east",
432432
SystemId: "sys1",
433-
CreatedAt: "2024-01-01T00:00:00Z",
433+
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
434434
},
435435
wantMatch: true,
436436
wantErr: false,
@@ -889,7 +889,7 @@ func TestMatch_CelSelector_Environment(t *testing.T) {
889889
Id: "1",
890890
Name: "production",
891891
SystemId: "sys1",
892-
CreatedAt: "2024-01-01T00:00:00Z",
892+
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
893893
},
894894
wantMatch: true,
895895
wantErr: false,
@@ -901,7 +901,7 @@ func TestMatch_CelSelector_Environment(t *testing.T) {
901901
Id: "2",
902902
Name: "staging",
903903
SystemId: "sys1",
904-
CreatedAt: "2024-01-01T00:00:00Z",
904+
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
905905
},
906906
wantMatch: false,
907907
wantErr: false,
@@ -913,7 +913,7 @@ func TestMatch_CelSelector_Environment(t *testing.T) {
913913
Id: "3",
914914
Name: "production-us-east",
915915
SystemId: "sys1",
916-
CreatedAt: "2024-01-01T00:00:00Z",
916+
CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
917917
},
918918
wantMatch: true,
919919
wantErr: false,

apps/workspace-engine/pkg/workspace/releasemanager/deployment/planner_bench_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func createTestSystem(workspaceID, id, name string) *oapi.System {
2727
}
2828

2929
func createTestEnvironment(systemID, id, name string) *oapi.Environment {
30-
now := time.Now().Format(time.RFC3339)
3130
selector := &oapi.Selector{}
3231
_ = selector.FromCelSelector(oapi.CelSelector{Cel: "true"})
3332

@@ -38,7 +37,7 @@ func createTestEnvironment(systemID, id, name string) *oapi.Environment {
3837
Description: &description,
3938
SystemId: systemID,
4039
ResourceSelector: selector,
41-
CreatedAt: now,
40+
CreatedAt: time.Now(),
4241
}
4342
}
4443

apps/workspace-engine/pkg/workspace/releasemanager/deployment/planner_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func createTestSystemForPlanner(workspaceID, id, name string) *oapi.System {
4141
}
4242

4343
func createTestEnvironmentForPlanner(systemID, id, name string) *oapi.Environment {
44-
now := time.Now().Format(time.RFC3339)
4544
selector := &oapi.Selector{}
4645
_ = selector.FromCelSelector(oapi.CelSelector{Cel: "true"})
4746

@@ -52,7 +51,7 @@ func createTestEnvironmentForPlanner(systemID, id, name string) *oapi.Environmen
5251
Description: &description,
5352
SystemId: systemID,
5453
ResourceSelector: selector,
55-
CreatedAt: now,
54+
CreatedAt: time.Now(),
5655
}
5756
}
5857

0 commit comments

Comments
 (0)