-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MutateCheck): add option for dataset mutation checks, ExecFile -…
…> ExecScript
- Loading branch information
Showing
4 changed files
with
98 additions
and
37 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,29 @@ | ||
package ds | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
starlark "github.com/google/skylark" | ||
) | ||
|
||
func TestCheckFields(t *testing.T) { | ||
fieldErr := fmt.Errorf("can't mutate this field") | ||
allErrCheck := func(fields ...string) error { | ||
return fieldErr | ||
} | ||
ds := NewDataset(nil, nil, allErrCheck) | ||
thread := &starlark.Thread{} | ||
|
||
if _, err := ds.SetBody(thread, nil, starlark.Tuple{starlark.String("data")}, nil); err != fieldErr { | ||
t.Errorf("expected fieldErr, got: %s", err) | ||
} | ||
|
||
if _, err := ds.SetMeta(thread, nil, starlark.Tuple{starlark.String("key"), starlark.String("value")}, nil); err != fieldErr { | ||
t.Errorf("expected fieldErr, got: %s", err) | ||
} | ||
|
||
if _, err := ds.SetSchema(thread, nil, starlark.Tuple{starlark.String("wut")}, nil); err != fieldErr { | ||
t.Errorf("expected fieldErr, got: %s", err) | ||
} | ||
} |
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