@@ -39,6 +39,10 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils {
39
39
tableName = " big_serial_table_overflow" ,
40
40
primaryKeyField = " id" ,
41
41
primaryKeyDataType = PrimaryKeyDataType .BigSerial
42
+ ),
43
+ TableSettings (
44
+ tableName = " bytea_table" ,
45
+ primaryKeyField = " id"
42
46
)
43
47
)
44
48
val dataExplorerConfig : DataExplorerConfig = DataExplorerConfig (" http://localhost:9000" , dataExplorerConfigTables)
@@ -50,6 +54,7 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils {
50
54
def bigSerialSettings : TableSettings = dataExplorerConfig.tablesSettings(4 )
51
55
def serialOverflowSettings : TableSettings = dataExplorerConfig.tablesSettings(5 )
52
56
def bigSerialOverflowSettings : TableSettings = dataExplorerConfig.tablesSettings(6 )
57
+ def byteaSettings : TableSettings = dataExplorerConfig.tablesSettings(7 )
53
58
54
59
def isValidUUID (str : String ): Boolean = {
55
60
if (str == null ) return false
@@ -70,12 +75,13 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils {
70
75
" return tables from modules" in withApiClient { client =>
71
76
val response = client.getTables.futureValue
72
77
response.data.map(_.name) match
73
- case List (users, userLogs, uuidTable, serialTable, bigSerialTable, _, _) =>
78
+ case List (users, userLogs, uuidTable, serialTable, bigSerialTable, _, _, byteaTable ) =>
74
79
users must be(usersSettings.tableName)
75
80
userLogs must be(userLogsSettings.tableName)
76
81
uuidTable must be(uuidSettings.tableName)
77
82
serialTable must be(serialSettings.tableName)
78
83
bigSerialTable must be(bigSerialSettings.tableName)
84
+ byteaTable must be(byteaSettings.tableName)
79
85
case list => fail(s " Unexpected response: ${list.mkString(" , " )}" )
80
86
}
81
87
@@ -135,6 +141,17 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils {
135
141
bigSerialSettings.filterableColumns must be(List .empty)
136
142
bigSerialSettings.createSettings.nonRequiredColumns must be(List .empty)
137
143
bigSerialSettings.createSettings.requiredColumns must be(List .empty)
144
+
145
+ val head6 = response.data(5 )
146
+ head6.primaryKeyName must be(byteaSettings.primaryKeyField)
147
+ byteaSettings.referenceField must be(None )
148
+ byteaSettings.hiddenColumns must be(List .empty)
149
+ byteaSettings.nonEditableColumns must be(List .empty)
150
+ byteaSettings.canBeDeleted must be(true )
151
+ byteaSettings.columnTypeOverrides must be(Map .empty)
152
+ byteaSettings.filterableColumns must be(List .empty)
153
+ byteaSettings.createSettings.nonRequiredColumns must be(List .empty)
154
+ byteaSettings.createSettings.requiredColumns must be(List .empty)
138
155
}
139
156
}
140
157
@@ -680,7 +697,7 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils {
680
697
681
698
responseMetadata.head.nonEmpty mustBe true
682
699
}
683
-
700
+
684
701
" return new user id" in withApiClient { implicit client =>
685
702
val user = createUser.futureValue
686
703
val response = client.getTableMetadata(usersSettings.tableName, List (" name" , " ASC" ), List (0 , 9 ), " {}" ).futureValue
@@ -737,6 +754,18 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils {
737
754
s " ERROR: nextval: reached maximum value of sequence \" big_serial_table_overflow_seq \" (9223372036854775807) "
738
755
)
739
756
}
757
+
758
+ " create a new bytea" in withApiClient { implicit client =>
759
+ val stringBytea = " [0, 10, 20, 30]"
760
+ // The response returns the bytea as Hex; this would be its equivalent in Hex.
761
+ val correctValue = " \\ x000a141e"
762
+ val request = AdminCreateTable .Request (Map (" data" -> stringBytea))
763
+ val byteaId = client.createItem(byteaSettings.tableName, request).futureValue.id
764
+
765
+ val response = client.viewItem(byteaSettings.tableName, byteaId).futureValue
766
+ val dataResponse = response.find(_._1 == " data" ).value._2
767
+ dataResponse must be(correctValue)
768
+ }
740
769
}
741
770
742
771
" fail when field in request doesn't exists" in withApiClient { client =>
@@ -779,6 +808,22 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils {
779
808
emailResponse must be(email)
780
809
}
781
810
811
+ " update a new bytea" in withApiClient { client =>
812
+ val request = AdminCreateTable .Request (Map (" data" -> " [10, 10, 10, 10]" ))
813
+ val byteaId = client.createItem(byteaSettings.tableName, request).futureValue.id
814
+
815
+ val stringBytea = " [0, 10, 20, 30]"
816
+ // The response returns the bytea as Hex; this would be its equivalent in Hex.
817
+ val correctValue = " \\ x000a141e"
818
+ val updateRequest = AdminUpdateTable .Request (Map (" data" -> stringBytea))
819
+ val updateResponse = client.updateItem(byteaSettings.tableName, byteaId, updateRequest).futureValue
820
+
821
+ val newResponse = client.viewItem(byteaSettings.tableName, byteaId).futureValue
822
+ val dataResponse = newResponse.find(_._1 == " data" ).value._2
823
+ updateResponse.id must be(byteaId)
824
+ dataResponse must be(correctValue)
825
+ }
826
+
782
827
" update a new row for all tables" in withApiClient { client =>
783
828
val tables = List (serialSettings, bigSerialSettings)
784
829
for (table <- tables) {
0 commit comments