Skip to content

Commit

Permalink
fix linst test error
Browse files Browse the repository at this point in the history
  • Loading branch information
hexaforce committed Feb 12, 2025
1 parent 33fef63 commit d605405
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions server/e2e/gql_asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestCoreSupportGetAssets(t *testing.T) {
}.Wrap(),
})
assert.Nil(t, err)
assert.Equal(t, len(as), 3)
assert.Equal(t, len(as), 4)

res = getAssets(e, teamId, nil)
assets := res.Path("$.data.assets.nodes").Array().Iter()
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestAssociateProjectGetAssets(t *testing.T) {
// Get none project(Workspace) >>> test.png, test.csv
res = getAssets(e, teamId, nil)
assets = res.Path("$.data.assets.nodes").Array()
assets.Length().IsEqual(2)
assets.Length().IsEqual(3)
assets.Value(0).Object().HasValue("name", "test.csv")
assets.Value(1).Object().HasValue("name", "test.png")

Expand All @@ -190,7 +190,7 @@ func TestAssociateProjectGetAssets(t *testing.T) {

res = getAssets(e, teamId, nil)
assets = res.Path("$.data.assets.nodes").Array()
assets.Length().IsEqual(0)
assets.Length().IsEqual(1)
}

const CreateAssetMutation = `mutation CreateAsset($teamId: ID!, $projectId: ID, $file: Upload!, $coreSupport: Boolean!) {
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/kennygrant/sanitize v1.2.4
github.com/labstack/echo/v4 v4.13.3
github.com/mitchellh/mapstructure v1.5.0
github.com/oklog/ulid v1.3.1
github.com/pkg/errors v0.9.1
github.com/ravilushqa/otelgqlgen v0.17.0
github.com/reearth/orb v0.0.0-20250123044717-f6f70ce16355
Expand Down Expand Up @@ -131,6 +130,7 @@ require (
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion server/internal/infrastructure/fs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (f *fileRepo) RemoveAsset(ctx context.Context, u *url.URL) error {
return nil
}
p := sanitize.Path(u.Path)
if p == "" || f.urlBase == nil || u.Scheme != f.urlBase.Scheme || u.Host != f.urlBase.Host || path.Dir(p) != f.urlBase.Path {
if p == "" || f.urlBase == nil || u.Scheme != f.urlBase.Scheme || u.Host != f.urlBase.Host || path.Dir(p) != filepath.Join(f.urlBase.Path, assetDir) {
return gateway.ErrInvalidFile
}
return f.delete(ctx, filepath.Join(assetDir, filepath.Base(p)))
Expand Down
8 changes: 4 additions & 4 deletions server/internal/infrastructure/fs/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func TestFSFile_UploadAssetFromURL(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
testGCS.UploadTestData(srcBucket, tc.fileName)

fsBaseURL := "/assets"
newFileRepo, err := NewFile(mockFs(), fsBaseURL)
// fsBaseURL := "/assets"
newFileRepo, err := NewFile(mockFs(), "/")
assert.NoError(t, err)

srcURL, _ := url.Parse(fmt.Sprintf("%s/%s", tc.filePath, tc.fileName))
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestFile_RemoveAsset(t *testing.T) {
t.Parallel()

fs := mockFs()
f, _ := NewFile(fs, "https://example.com/assets")
f, _ := NewFile(fs, "https://example.com/")

u, _ := url.Parse(tc.URL)
err := f.RemoveAsset(context.Background(), u)
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestFile_RemoveBuiltScene(t *testing.T) {
func TestGetAssetFileURL(t *testing.T) {
e, err := url.Parse("http://hoge.com/assets/xxx.yyy")
assert.NoError(t, err)
b, err := url.Parse("http://hoge.com/assets")
b, err := url.Parse("http://hoge.com/")
assert.NoError(t, err)
assert.Equal(t, e, getAssetFileURL(b, "xxx.yyy"))
}
Expand Down

0 comments on commit d605405

Please sign in to comment.