generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement Snapshotting on schema state machine (#4246)
Converts the state to a list of schemas, and back by using runtime values. This assumes that the runtime values match the schema state structure. If not, it is a bug we need to fix. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
38be24f
commit d577494
Showing
9 changed files
with
649 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package schemaservice | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
"github.com/block/ftl/common/schema" | ||
"github.com/block/ftl/internal/key" | ||
) | ||
|
||
func TestSchemaStateMarshalling(t *testing.T) { | ||
k := key.NewDeploymentKey("test") | ||
state := SchemaState{ | ||
deployments: map[key.Deployment]*schema.Module{ | ||
k: { | ||
Name: "test", | ||
Runtime: &schema.ModuleRuntime{ | ||
Deployment: &schema.ModuleRuntimeDeployment{ | ||
DeploymentKey: k, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
bytes, err := state.Marshal() | ||
if err != nil { | ||
t.Fatalf("failed to marshal schema state: %v", err) | ||
} | ||
|
||
unmarshalledState := NewSchemaState() | ||
if err := unmarshalledState.Unmarshal(bytes); err != nil { | ||
t.Fatalf("failed to unmarshal schema state: %v", err) | ||
} | ||
|
||
assert.Equal(t, state, unmarshalledState) | ||
} |
Oops, something went wrong.