-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws_s3_service_test.go
59 lines (54 loc) · 1.65 KB
/
aws_s3_service_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package smile_databricks_gateway
import (
"fmt"
"reflect"
"testing"
)
func TestAWSS3(t *testing.T) {
awsS3Service := NewAWSS3Service(TestConfig.SAML2AWSBin, TestConfig.SAMLProfile, TestConfig.SAMLRegion, TestConfig.AWSDestBucket)
t.Run("PutRequest", func(t *testing.T) {
putRequest, err := UnmarshalT[SmileRequest]([]byte(RequestJSON))
if err != nil {
t.Fatalf("cannot unmarshal request: %q", err)
}
filename := fmt.Sprintf("%s_request.json", putRequest.IgoRequestID)
err = awsS3Service.PutRequest(filename, putRequest)
if err != nil {
t.Fatalf("cannot PutRequest: %q", err)
}
gotRequest, err := awsS3Service.GetRequestObject(filename)
if err != nil {
t.Fatalf("cannot GetRequest: %q", err)
}
if !reflect.DeepEqual(gotRequest, putRequest) {
t.Errorf("got %v want %v", gotRequest, putRequest)
}
err = awsS3Service.DeleteObject(filename)
if err != nil {
t.Fatalf("cannot DeleteObject: %q", err)
}
})
t.Run("PutSample", func(t *testing.T) {
putRequest, err := UnmarshalT[SmileRequest]([]byte(RequestJSON))
if err != nil {
t.Fatalf("cannot unmarshal request: %q", err)
}
putSample := putRequest.Samples[0]
filename := fmt.Sprintf("%s_sample.json", putSample.SampleName)
err = awsS3Service.PutSample(filename, putSample)
if err != nil {
t.Fatalf("cannot PutSample: %q", err)
}
gotSample, err := awsS3Service.GetSampleObject(filename)
if err != nil {
t.Fatalf("cannot GetSample: %q", err)
}
if !reflect.DeepEqual(gotSample, putSample) {
t.Errorf("got %v want %v", gotSample, putSample)
}
err = awsS3Service.DeleteObject(filename)
if err != nil {
t.Fatalf("cannot DeleteObject: %q", err)
}
})
}