-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
102 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ steps: | |
- name: test | ||
image: golang | ||
commands: | ||
- go test | ||
- go test -v -failfast -cover ./lib | ||
- go build |
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,12 @@ | ||
package lib | ||
|
||
import "testing" | ||
|
||
func TestSum(t *testing.T) { | ||
he := HistoricalExecution{} | ||
|
||
err := RenderHistoryResults([]HistoricalExecution{he}, "csv") | ||
if err != nil { | ||
t.Errorf("Unable to render as %s", "csv") | ||
} | ||
} |
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,31 @@ | ||
package lib | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func init() { | ||
svc = &mockAthenaClient{} | ||
downloader = &mockDownloaderAPI{} | ||
} | ||
|
||
func Test_QueryExecute(t *testing.T) { | ||
q := Query{ | ||
Database: "default", | ||
SQL: "SELECT 1", | ||
OutputFile: "/dev/stdout", | ||
QueryResultsBucket: "test", | ||
Format: "csv", | ||
Statistics: false, | ||
} | ||
|
||
f, err := q.Execute() | ||
if err != nil { | ||
t.Errorf("Could note Execute() query: %v", err.Error()) | ||
return | ||
} | ||
|
||
fmt.Println(f.Name()) | ||
|
||
} |
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,45 @@ | ||
package lib | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/athena" | ||
"github.com/aws/aws-sdk-go/service/athena/athenaiface" | ||
"github.com/aws/aws-sdk-go/service/s3" | ||
"github.com/aws/aws-sdk-go/service/s3/s3manager" | ||
"github.com/aws/aws-sdk-go/service/s3/s3manager/s3manageriface" | ||
) | ||
|
||
// Define a mock struct to be used in your unit tests of myFunc. | ||
type mockAthenaClient struct { | ||
athenaiface.AthenaAPI | ||
} | ||
|
||
func (m *mockAthenaClient) StartQueryExecution(input *athena.StartQueryExecutionInput) (*athena.StartQueryExecutionOutput, error) { | ||
// mock response/functionality | ||
return &athena.StartQueryExecutionOutput{ | ||
QueryExecutionId: aws.String("xxxyyyzzz"), | ||
}, nil | ||
} | ||
|
||
func (m *mockAthenaClient) GetQueryExecution(input *athena.GetQueryExecutionInput) (*athena.GetQueryExecutionOutput, error) { | ||
// mock response/functionality | ||
return &athena.GetQueryExecutionOutput{ | ||
QueryExecution: &athena.QueryExecution{ | ||
QueryExecutionId: aws.String("xxxyyyzzz"), | ||
Status: &athena.QueryExecutionStatus{ | ||
State: aws.String(athena.QueryExecutionStateSucceeded), | ||
}, | ||
}, | ||
}, nil | ||
} | ||
|
||
// mock the downloader | ||
type mockDownloaderAPI struct { | ||
s3manageriface.DownloaderAPI | ||
} | ||
|
||
func (m *mockDownloaderAPI) Download(io.WriterAt, *s3.GetObjectInput, ...func(*s3manager.Downloader)) (int64, error) { | ||
return 100, nil | ||
} |