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

Function TestValidateAttributesUnit

admin/database/postgres/postgres_test.go:860–990  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

858}
859
860func TestValidateAttributesUnit(t *testing.T) {
861 c := &connection{}
862
863 tests := []struct {
864 name string
865 attributes map[string]any
866 expectError bool
867 errorMsg string
868 }{
869 {
870 name: "valid attributes",
871 attributes: map[string]any{
872 "valid_key_123": "value",
873 "another_key": "another value",
874 "key123": "value123",
875 "Key_With_Caps": "value",
876 },
877 expectError: false,
878 },
879 {
880 name: "empty attributes",
881 attributes: map[string]any{},
882 expectError: false,
883 },
884 {
885 name: "nil attributes",
886 attributes: nil,
887 expectError: false,
888 },
889 {
890 name: "invalid key with hyphen",
891 attributes: map[string]any{
892 "invalid-key": "value",
893 },
894 expectError: true,
895 errorMsg: "invalid attribute key 'invalid-key': must contain only alphanumeric characters and underscores",
896 },
897 {
898 name: "invalid key with space",
899 attributes: map[string]any{
900 "invalid key": "value",
901 },
902 expectError: true,
903 errorMsg: "invalid attribute key 'invalid key': must contain only alphanumeric characters and underscores",
904 },
905 {
906 name: "invalid key with special characters",
907 attributes: map[string]any{
908 "key@example": "value",
909 },
910 expectError: true,
911 errorMsg: "invalid attribute key 'key@example': must contain only alphanumeric characters and underscores",
912 },
913 {
914 name: "empty key",
915 attributes: map[string]any{
916 "": "value",
917 },

Callers

nothing calls this directly

Calls 4

validateAttributesMethod · 0.95
ContainsMethod · 0.80
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected