Skip to content

Commit

Permalink
完善测试
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Dec 10, 2024
1 parent 6bfa73b commit 8d13ab5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
goVer: ['1.18', '1.19', '1.21', '1.22', '1.23']
goVer: ['1.20', '1.21', '1.22', '1.23']

steps:
- name: Checkout
Expand Down
31 changes: 23 additions & 8 deletions filesystem/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ func Test_ListContents(t *testing.T) {
}
}

assertEqual(useRes, check, "Test_ListContents")
assertEqual(useRes["path"], check["path"], "Test_ListContents path")
assertEqual(useRes["size"], check["size"], "Test_ListContents size")
assertEqual(useRes["type"], check["type"], "Test_ListContents type")

ts := check["timestamp"].(int64)
if useRes["timestamp"].(int64) < ts {
t.Errorf("timestamp got %d, want %d", useRes["timestamp"], ts)
}
}

func Test_Has(t *testing.T) {
Expand Down Expand Up @@ -108,8 +115,6 @@ func Test_GetMimetype(t *testing.T) {
}

func Test_GetTimestamp(t *testing.T) {
assertEqual := assertEqualT(t)

// 根目录
root := "./testdata"
adapter := local_adapter.New(root)
Expand All @@ -121,12 +126,13 @@ func Test_GetTimestamp(t *testing.T) {
t.Fatal(err.Error())
}

assertEqual(res, int64(1733803713), "Test_GetTimestamp")
ts := int64(1733803713)
if res < ts {
t.Errorf("got %d, want %d", res, ts)
}
}

func Test_GetVisibility(t *testing.T) {
assertEqual := assertEqualT(t)

// 根目录
root := "./testdata"
adapter := local_adapter.New(root)
Expand All @@ -138,7 +144,9 @@ func Test_GetVisibility(t *testing.T) {
t.Fatal(err.Error())
}

assertEqual(res, "666", "Test_GetTimestamp")
if res != "666" && res != "public" {
t.Error("GetVisibility fail")
}
}

func Test_GetSize(t *testing.T) {
Expand Down Expand Up @@ -181,7 +189,14 @@ func Test_GetMetadata(t *testing.T) {
"type": "file",
}

assertEqual(res, check, "Test_GetMetadata")
assertEqual(res["path"], check["path"], "Test_ListContents path")
assertEqual(res["size"], check["size"], "Test_ListContents size")
assertEqual(res["type"], check["type"], "Test_ListContents type")

ts := check["timestamp"].(int64)
if res["timestamp"].(int64) < ts {
t.Errorf("timestamp got %d, want %d", res["timestamp"], ts)
}
}

func Test_Write(t *testing.T) {
Expand Down

0 comments on commit 8d13ab5

Please sign in to comment.