-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new methods to artifact interface: Read, write, parse url (#92)
* Add new methods to artifact interface: Read, write, parse url * Fix typo * Address review
- Loading branch information
Arief Rahmansyah
authored
Dec 8, 2023
1 parent
b3d74d1
commit 1755960
Showing
3 changed files
with
245 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package artifact | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"cloud.google.com/go/storage" | ||
) | ||
|
||
func TestGcsArtifactClient_ParseURL(t *testing.T) { | ||
type fields struct { | ||
API *storage.Client | ||
} | ||
type args struct { | ||
gsURL string | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
want *URL | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "valid short url", | ||
fields: fields{ | ||
API: nil, | ||
}, | ||
args: args{ | ||
gsURL: "gs://bucket-name/object-path", | ||
}, | ||
want: &URL{ | ||
Bucket: "bucket-name", | ||
Object: "object-path", | ||
}, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "valid url", | ||
fields: fields{ | ||
API: nil, | ||
}, | ||
args: args{ | ||
gsURL: "gs://bucket-name/object-path/object-path-2/object-path-3/file-1.txt", | ||
}, | ||
want: &URL{ | ||
Bucket: "bucket-name", | ||
Object: "object-path/object-path-2/object-path-3/file-1.txt", | ||
}, | ||
wantErr: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gac := &GcsArtifactClient{ | ||
API: tt.fields.API, | ||
} | ||
got, err := gac.ParseURL(tt.args.gsURL) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("GcsArtifactClient.ParseURL() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("GcsArtifactClient.ParseURL() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.