diff options
author | 2022-05-08 19:49:45 +0200 | |
---|---|---|
committer | 2022-05-08 18:49:45 +0100 | |
commit | 5004e0a9da665ccc0e18cd4075ee636641b71f0a (patch) | |
tree | b7c8269b954ced61afa9fffd7305bd88acca6f8e /vendor/codeberg.org/gruf/go-bitutil/test.tpl | |
parent | [bugfix] Fix existing bio text showing as HTML (#531) (diff) | |
download | gotosocial-5004e0a9da665ccc0e18cd4075ee636641b71f0a.tar.xz |
[bugfix] Fix remote media pruning failing if media already gone (#548)
* fix error check of prune to allow missing files
* update go-store library, add test for pruning item with db entry but no file
Signed-off-by: kim <grufwub@gmail.com>
* remove now-unneccessary error check
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-bitutil/test.tpl')
-rw-r--r-- | vendor/codeberg.org/gruf/go-bitutil/test.tpl | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-bitutil/test.tpl b/vendor/codeberg.org/gruf/go-bitutil/test.tpl new file mode 100644 index 000000000..4e659d81f --- /dev/null +++ b/vendor/codeberg.org/gruf/go-bitutil/test.tpl @@ -0,0 +1,60 @@ +package atomics_test + +import ( + "atomic" + "unsafe" + "testing" + + "codeberg.org/gruf/go-atomics" +) + +func Test{{ .Name }}StoreLoad(t *testing.T) { + for _, test := range {{ .Name }}Tests { + val := atomics.New{{ .Name }}() + + val.Store(test.V1) + + if !({{ call .Compare "val.Load()" "test.V1" }}) { + t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V1) + } + + val.Store(test.V2) + + if !({{ call .Compare "val.Load()" "test.V2" }}) { + t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V2) + } + } +} + +func Test{{ .Name }}CAS(t *testing.T) { + for _, test := range {{ .Name }}Tests { + val := atomics.New{{ .Name }}() + + val.Store(test.V1) + + if val.CAS(test.V2, test.V1) { + t.Fatalf("failed testing negative .CAS: test=%+v state=%v", test, val.Load()) + } + + if !val.CAS(test.V1, test.V2) { + t.Fatalf("failed testing positive .CAS: test=%+v state=%v", test, val.Load()) + } + } +} + +func Test{{ .Name }}Swap(t *testing.T) { + for _, test := range {{ .Name }}Tests { + val := atomics.New{{ .Name }}() + + val.Store(test.V1) + + if !({{ call .Compare "val.Swap(test.V2)" "test.V1" }}) { + t.Fatal("failed testing .Swap") + } + + if !({{ call .Compare "val.Swap(test.V1)" "test.V2" }}) { + t.Fatal("failed testing .Swap") + } + } +} + |