Fix small error message in tests
- Ensure we check foreign key values with reload AFTER we do all our relationship struct checks, reloading kills the relationship struct.
This commit is contained in:
parent
8cdb026200
commit
a58d588150
1 changed files with 15 additions and 14 deletions
|
@ -38,6 +38,20 @@ func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if a.R.{{$txt.Function.Name}} != x {
|
||||
t.Error("relationship struct not set to correct value")
|
||||
}
|
||||
|
||||
{{if .Unique -}}
|
||||
if x.R.{{$txt.Function.ForeignName}} != &a {
|
||||
t.Error("failed to append to foreign relationship struct")
|
||||
}
|
||||
{{else -}}
|
||||
if x.R.{{$txt.Function.ForeignName}}[0] != &a {
|
||||
t.Error("failed to append to foreign relationship struct")
|
||||
}
|
||||
{{end -}}
|
||||
|
||||
{{if $txt.Function.UsesBytes -}}
|
||||
if 0 != bytes.Compare(a.{{$txt.Function.LocalAssignment}}, x.{{$txt.Function.ForeignAssignment}}) {
|
||||
{{else -}}
|
||||
|
@ -45,9 +59,6 @@ func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt
|
|||
{{end -}}
|
||||
t.Error("foreign key was wrong value", a.{{$txt.Function.LocalAssignment}})
|
||||
}
|
||||
if a.R.{{$txt.Function.Name}} != x {
|
||||
t.Error("relationship struct not set to correct value")
|
||||
}
|
||||
|
||||
zero := reflect.Zero(reflect.TypeOf(a.{{$txt.Function.LocalAssignment}}))
|
||||
reflect.Indirect(reflect.ValueOf(&a.{{$txt.Function.LocalAssignment}})).Set(zero)
|
||||
|
@ -63,16 +74,6 @@ func test{{$txt.LocalTable.NameGo}}ToOneSetOp{{$txt.ForeignTable.NameGo}}_{{$txt
|
|||
{{end -}}
|
||||
t.Error("foreign key was wrong value", a.{{$txt.Function.LocalAssignment}}, x.{{$txt.Function.ForeignAssignment}})
|
||||
}
|
||||
|
||||
{{if .Unique -}}
|
||||
if x.R.{{$txt.Function.ForeignName}} != &a {
|
||||
t.Error("failed to append to foreign relationship struct")
|
||||
}
|
||||
{{else -}}
|
||||
if x.R.{{$txt.Function.ForeignName}}[0] != &a {
|
||||
t.Error("failed to append to foreign relationship struct")
|
||||
}
|
||||
{{end -}}
|
||||
}
|
||||
}
|
||||
{{- if .Nullable}}
|
||||
|
@ -119,7 +120,7 @@ func test{{$txt.LocalTable.NameGo}}ToOneRemoveOp{{$txt.ForeignTable.NameGo}}_{{$
|
|||
}
|
||||
|
||||
if a.{{$txt.LocalTable.ColumnNameGo}}.Valid {
|
||||
t.Error("R struct entry should be nil")
|
||||
t.Error("foreign key value should be nil")
|
||||
}
|
||||
|
||||
{{if .Unique -}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue