Documentation
¶
Index ¶
- func AssertComp(t *testing.T, target string, expect string)
- func AssertContainStr(t *testing.T, target any, str string)
- func AssertDeepEqual(t *testing.T, target any, expect any)
- func AssertEqual(t *testing.T, target any, expect any)
- func AssertEqualFatal(t *testing.T, target any, expect any)
- func AssertErrorAs(t *testing.T, target error, expect any)
- func AssertFalse(t *testing.T, target any)
- func AssertJsonExact(t *testing.T, targetJson string, expectJson string, ignoreValues []string)
- func AssertNotDeepEqual(t *testing.T, target any, expect any)
- func AssertNotEqual(t *testing.T, target any, shouldNotBe any)
- func AssertNotEqualFatal(t *testing.T, target any, shouldNotBe any)
- func AssertNotTypedNil[T any](t *testing.T, target *T)
- func AssertNotUnTypedNil(t *testing.T, target any)
- func AssertTrue(t *testing.T, target any)
- func AssertTypedNil[T any](t *testing.T, target *T)
- func AssertUnTypedNil(t *testing.T, target any)
- func GetFirst[A any](a A, b ...any) A
- func GetLast(a ...any) any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFalse ¶
func AssertJsonExact ¶
文字列のjsonを受け取ってmapにしてDiffを取る。 完全一致比較。(余計なフィールドがあってもエラーとなり、不足してもエラーとなる)
現状、最上位が{}で囲まれているJSONのみに対応している これは、json.Unmarshalした際に、最上位がmap[string]interface{}となるもので、 例えば、[0,1,2,3] や 3 はエラーとなる。
ignoreValuesで指定したフィールドはデフォルト値とすることができる。 ignoreValuesはドット区切りで指定する。(例)data.entity.user.id したがってフィールドが存在することをチェックしたいが値自体には関心がない場合に、 ignoreValuesを指定した上で、expectJsonの対象のフィールドを stringなら"", intなら0, boolならfalse, に指定すれば良い。
(24/8/17対応)ignoreValuesは途中が配列の場合は全ての子要素に適用される。 例えば"data.id"のように指定した際に、{"data": [{"id":1}, {"id":2}, ...]}の全ての子要素に 適用される。ただし{"data": [[ {"id":1} ]] }のように入れ子の配列には適用されない。
ブロックを指定(例えば、data.entity.userとした際にuser内に各種キーが含まれる場合)した場合は、その中身が再帰的に全てデフォルト値になる。 (user内のプロパティが消えて空のマップとなるわけではなく、中のキーそれぞれがデフォルト値になる点に注意。) *.fieldNameのように指定すると階層に関係なくすべての"fieldName" をデフォルト値にする。(ただ、mapを全走査するので効率は悪い。) *は必ず先頭に置いて直後にフィールドを指定する必要がある。 aaa.*.fieldNameや、*.aaa.fieldNameといった指定はできない。
日時はJSON上は単なる文字列のため、ゼロバリューは空文字となる。
func AssertNotTypedNil ¶
func AssertNotUnTypedNil ¶
func AssertTrue ¶
func AssertTypedNil ¶
func AssertUnTypedNil ¶
Types ¶
This section is empty.