mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-23 22:40:24 +02:00
(experimental) upgraded to encoding/json/v2
This commit is contained in:
1 parent
4d4275c9aa
commit
97dd775455
125 files changed
+433
-364
No files matched your search
@@ -64,8 +64,8 @@ func TestNewFileFromPath(t *testing.T) {
|
||||
if match, err := regexp.Match(normalizedNamePattern, []byte(f.Name)); !match {
|
||||
t.Fatalf("Expected Name to match %v, got %q (%v)", normalizedNamePattern, f.Name, err)
|
||||
}
|
||||
if f.Size != 73 {
|
||||
t.Fatalf("Expected Size %v, got %v", 73, f.Size)
|
||||
if f.Size != 77 {
|
||||
t.Fatalf("Expected Size %v, got %v", 77, f.Size)
|
||||
}
|
||||
if _, ok := f.Reader.(*filesystem.PathReader); !ok {
|
||||
t.Fatalf("Expected Reader to be PathReader, got %v", f.Reader)
|
||||
|
||||
@@ -444,7 +444,7 @@ func TestFilesystemServe(t *testing.T) {
|
||||
map[string]string{
|
||||
"Content-Disposition": `inline; filename="test_name.png"`,
|
||||
"Content-Type": "image/png",
|
||||
"Content-Length": "73",
|
||||
"Content-Length": "77",
|
||||
"Content-Security-Policy": csp,
|
||||
"Cache-Control": cacheControl,
|
||||
},
|
||||
@@ -459,7 +459,7 @@ func TestFilesystemServe(t *testing.T) {
|
||||
map[string]string{
|
||||
"Content-Disposition": `attachment; filename="test_name_download.png"`,
|
||||
"Content-Type": "image/png",
|
||||
"Content-Length": "73",
|
||||
"Content-Length": "77",
|
||||
"Content-Security-Policy": csp,
|
||||
"Cache-Control": cacheControl,
|
||||
},
|
||||
@@ -792,8 +792,8 @@ func TestFilesystemCopy(t *testing.T) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
if f.Size() != 73 {
|
||||
t.Fatalf("Expected file size %d, got %d", 73, f.Size())
|
||||
if f.Size() != 77 {
|
||||
t.Fatalf("Expected file size %d, got %d", 77, f.Size())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,7 +895,7 @@ func TestFilesystemServeSingleRange(t *testing.T) {
|
||||
t.Fatalf("Expected StatusCode %d, got %d", http.StatusPartialContent, result.StatusCode)
|
||||
}
|
||||
|
||||
expectedRange := "bytes 0-20/73"
|
||||
expectedRange := "bytes 0-20/77"
|
||||
if cr := result.Header.Get("Content-Range"); cr != expectedRange {
|
||||
t.Fatalf("Expected Content-Range %q, got %q", expectedRange, cr)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package fileblob
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/json/v2"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
@@ -50,7 +50,8 @@ func setAttrs(path string, xa xattrs) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(f).Encode(xa); err != nil {
|
||||
err = json.MarshalWrite(f, xa)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
os.Remove(f.Name())
|
||||
return err
|
||||
@@ -75,7 +76,9 @@ func getAttrs(path string) (xattrs, error) {
|
||||
}
|
||||
|
||||
xa := new(xattrs)
|
||||
if err := json.NewDecoder(f).Decode(xa); err != nil {
|
||||
|
||||
err = json.UnmarshalRead(f, xa)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
return xattrs{}, err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package s3_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/json/v2"
|
||||
"encoding/xml"
|
||||
"testing"
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestResponseErrorSerialization(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
jsonRaw, err := json.Marshal(respErr)
|
||||
jsonRaw, err := json.Marshal(respErr, json.Deterministic(true))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package s3_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/json/v2"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -78,7 +78,7 @@ func TestS3GetObject(t *testing.T) {
|
||||
}
|
||||
|
||||
// check serialized attributes
|
||||
raw, err := json.Marshal(resp)
|
||||
raw, err := json.Marshal(resp, json.Deterministic(true))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package s3_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/json/v2"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestS3HeadObject(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
raw, err := json.Marshal(resp)
|
||||
raw, err := json.Marshal(resp, json.Deterministic(true))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package s3_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/json/v2"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -143,7 +143,7 @@ func TestS3ListObjects(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
raw, err := json.Marshal(resp)
|
||||
raw, err := json.Marshal(resp, json.Deterministic(true))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package s3blob_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/json/v2"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -261,7 +261,11 @@ func TestDriverAttributes(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
raw, err := json.Marshal(attrs)
|
||||
raw, err := json.Marshal(
|
||||
attrs,
|
||||
json.Deterministic(true),
|
||||
json.FormatNilSliceAsNull(true),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -362,7 +366,11 @@ func TestDriverListPaged(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
raw, err := json.Marshal(page)
|
||||
raw, err := json.Marshal(
|
||||
page,
|
||||
json.Deterministic(true),
|
||||
json.FormatNilSliceAsNull(true),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -510,7 +518,11 @@ func TestDriverNewRangeReader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
rawAttrs, err := json.Marshal(r.Attributes())
|
||||
rawAttrs, err := json.Marshal(
|
||||
r.Attributes(),
|
||||
json.Deterministic(true),
|
||||
json.FormatNilSliceAsNull(true),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user