MCPcopy Index your code
hub / github.com/rilldata/rill / TestModelChangeModes

Function TestModelChangeModes

runtime/parser/parser_test.go:2333–2386  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2331}
2332
2333func TestModelChangeModes(t *testing.T) {
2334 tests := []struct {
2335 name string
2336 yamlInput string
2337 wantMode string
2338 }{
2339 {
2340 name: "default change mode",
2341 yamlInput: `
2342type: model
2343connector: duckdb
2344`,
2345 wantMode: "MODEL_CHANGE_MODE_RESET",
2346 },
2347 {
2348 name: "manual change mode",
2349 yamlInput: `
2350type: model
2351connector: duckdb
2352change_mode: manual
2353`,
2354 wantMode: "MODEL_CHANGE_MODE_MANUAL",
2355 },
2356 {
2357 name: "patch change mode",
2358 yamlInput: `
2359type: model
2360connector: duckdb
2361change_mode: patch
2362`,
2363 wantMode: "MODEL_CHANGE_MODE_PATCH",
2364 },
2365 }
2366
2367 for _, tt := range tests {
2368 t.Run(fmt.Sprintf("Test %s", tt.name), func(t *testing.T) {
2369 ctx := context.Background()
2370 repo := makeRepo(t, map[string]string{
2371 `rill.yaml`: ``,
2372 `models/m1.yaml`: tt.yamlInput,
2373 })
2374
2375 p, err := Parse(ctx, repo, "", "", "duckdb", true)
2376 require.NoError(t, err)
2377 require.Len(t, p.Resources, 1)
2378 resource := p.Resources[ResourceName{Kind: ResourceKindModel, Name: "m1"}]
2379 require.NotNil(t, resource)
2380
2381 modelSpec := resource.ModelSpec
2382 require.NotNil(t, modelSpec)
2383 require.Equal(t, modelSpec.ChangeMode.String(), tt.wantMode, "expected change mode to be %s, got %s", tt.wantMode, modelSpec.ChangeMode.String())
2384 })
2385 }
2386}
2387
2388func TestModelAssertions(t *testing.T) {
2389 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

makeRepoFunction · 0.85
ParseFunction · 0.70
StringMethod · 0.65
RunMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected