Skip to content

Commit

Permalink
add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Mar 6, 2024
1 parent 6d7bfca commit 27ae2f6
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,13 @@ class MetacatSmokeSpec extends Specification {
def dto = api.getTable(catalogName, databaseName, tableName, false, true, true)
then:
metacatJson.convertValue(dto.getDefinitionMetadata().get('tags'), Set.class) == tags
tagApi.getTags() == tags
tagApi.search('tag', null, null, null).size() == 3
tagApi.search('tag', null, null, tableName).size() == 1
tagApi.search('tag', null, null, tableName).size() == 1
tagApi.list(tags, null, null, null, null, null).size() == 3
tagApi.list(tags, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(tags, null, null, null, "random_table", QualifiedName.Type.TABLE).size() == 0
cleanup:
tagApi.removeTableTags(catalogName, databaseName, tableName, true, [] as Set<String>)
api.deleteTable(catalogName, databaseName, tableName)
Expand Down Expand Up @@ -1661,6 +1668,63 @@ class MetacatSmokeSpec extends Specification {
's3-mysql-db' | 'smoke_db6' | 'part' | ['test_tag', 'unused'] as List<String> | false
}
def "Test tags for multiple tables #catalogName/#databaseName/#tableName"() {
setup:
def catalogName = "prodhive"
def databaseName = "default"
when:
createTable(catalogName, databaseName, "table1")
tagApi.setTableTags(catalogName, databaseName, "table1", ['table1', 'test'] as Set)
then:
tagApi.getTags().size() == 2
tagApi.list(['table1', 'test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.search('test', null, null, null).size() == 3
tagApi.search('table1', null, null, null).size() == 3
when:
createTable(catalogName, databaseName, "table2")
tagApi.setTableTags(catalogName, databaseName, "table2", ['table2', 'test'] as Set)
then:
tagApi.getTags().size() == 3
tagApi.list(['table1', 'test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['table2', 'test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 2
tagApi.search('test', null, null, null).size() == 4
tagApi.search('table1', null, null, null).size() == 3
tagApi.search('table2', null, null, null).size() == 3
when:
createTable(catalogName, databaseName, "table3")
tagApi.setTableTags(catalogName, databaseName, "table3", ['table3', 'unused'] as Set)
then:
tagApi.getTags().size() == 5
tagApi.list(['table1', 'test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['table2', 'test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 2
tagApi.list(['table3', 'unused'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['unused'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.search('test', null, null, null).size() == 4
tagApi.search('table1', null, null, null).size() == 3
tagApi.search('table2', null, null, null).size() == 3
tagApi.search('table3', null, null, null).size() == 3
tagApi.search('unused', null, null, null).size() == 3
when:
api.deleteTable(catalogName, databaseName, "table1")
then:
tagApi.getTags().size() == 5
tagApi.list(['table1', 'test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 0
tagApi.list(['table2', 'test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['test'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['table3', 'unused'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.list(['unused'] as Set<String>, null, null, null, null, QualifiedName.Type.TABLE).size() == 1
tagApi.search('test', null, null, null).size() == 3
tagApi.search('table1', null, null, null).size() == 0
tagApi.search('table2', null, null, null).size() == 3
tagApi.search('table3', null, null, null).size() == 3
tagApi.search('unused', null, null, null).size() == 3
cleanup:
api.deleteTable(catalogName, databaseName, "table2")
api.deleteTable(catalogName, databaseName, "table3")
}
@Unroll
def "Test tags for #catalogName/#databaseName/#tableName/#viewName"() {
when:
Expand Down

0 comments on commit 27ae2f6

Please sign in to comment.