mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
chore: join user information to workspace_build and template_version (#8625)
* include minimial user on template version and build * Add unit test to ensure join is superset
This commit is contained in:
@ -23,6 +23,34 @@ func TestViewSubsetTemplate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestViewSubsetTemplateVersion ensures TemplateVersionTable is a subset TemplateVersion
|
||||
func TestViewSubsetTemplateVersion(t *testing.T) {
|
||||
t.Parallel()
|
||||
table := reflect.TypeOf(database.TemplateVersionTable{})
|
||||
joined := reflect.TypeOf(database.TemplateVersion{})
|
||||
|
||||
tableFields := allFields(table)
|
||||
joinedFields := allFields(joined)
|
||||
if !assert.Subset(t, fieldNames(joinedFields), fieldNames(tableFields), "table is not subset") {
|
||||
t.Log("Some fields were added to the TemplateVersion Table without updating the 'template_version_with_user' view.")
|
||||
t.Log("See migration 000141_join_users_build_version.up.sql to create the view.")
|
||||
}
|
||||
}
|
||||
|
||||
// TestViewSubsetWorkspaceBuild ensures WorkspaceBuildTable is a subset of WorkspaceBuild
|
||||
func TestViewSubsetWorkspaceBuild(t *testing.T) {
|
||||
t.Parallel()
|
||||
table := reflect.TypeOf(database.WorkspaceBuildTable{})
|
||||
joined := reflect.TypeOf(database.WorkspaceBuild{})
|
||||
|
||||
tableFields := allFields(table)
|
||||
joinedFields := allFields(joined)
|
||||
if !assert.Subset(t, fieldNames(joinedFields), fieldNames(tableFields), "table is not subset") {
|
||||
t.Log("Some fields were added to the WorkspaceBuild Table without updating the 'workspace_build_with_user' view.")
|
||||
t.Log("See migration 000141_join_users_build_version.up.sql to create the view.")
|
||||
}
|
||||
}
|
||||
|
||||
func fieldNames(fields []reflect.StructField) []string {
|
||||
names := make([]string, len(fields))
|
||||
for i, field := range fields {
|
||||
|
Reference in New Issue
Block a user