Skip to content

Commit

Permalink
Finish unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cataldo committed Dec 14, 2023
1 parent ea2bb1f commit 3207d80
Show file tree
Hide file tree
Showing 7 changed files with 458 additions and 78 deletions.
18 changes: 0 additions & 18 deletions internal/util/util.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package util

import (
"bytes"
"encoding/gob"
"encoding/json"
"fmt"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
Expand Down Expand Up @@ -32,22 +30,6 @@ func ConvertToString(a any) string {
}
}

func ConvertToBytes(a any) ([]byte, error) {
if a == nil {
return nil, nil
}
t := reflect.TypeOf(a)
switch t.Kind() {
case reflect.Struct, reflect.Map, reflect.Slice, reflect.Array, reflect.Interface:
return json.Marshal(a)
default:
var buffer bytes.Buffer
enc := gob.NewEncoder(&buffer)
err := enc.Encode(a)
return buffer.Bytes(), err
}
}

func GetDataType(a any) string {
t := reflect.TypeOf(a)
switch t.Kind() {
Expand Down
4 changes: 2 additions & 2 deletions sqs/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestReceiveMessage(t *testing.T) {
t.Errorf("ReceiveMessage() error = %v, wantErr %v", r, tt.wantErr)
}
}()
initMessageString(tt.queueUrl)
initMessageString()
initMessageStruct(tt.queueUrl)
d := 5 * time.Second
if tt.name == "failed" {
Expand Down Expand Up @@ -43,7 +43,7 @@ func TestSimpleReceiveMessage(t *testing.T) {
t.Errorf("SimpleReceiveMessage() error = %v, wantErr %v", r, tt.wantErr)
}
}()
initMessageString(tt.queueUrl)
initMessageString()
initMessageStruct(tt.queueUrl)
d := 5 * time.Second
if tt.name == "failed" {
Expand Down
Loading

0 comments on commit 3207d80

Please sign in to comment.