-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* setup coveralls setups coveralls for test pipeline * codecov * codecov
- Loading branch information
1 parent
67ea2c7
commit 05da947
Showing
4 changed files
with
48 additions
and
23 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 |
---|---|---|
|
@@ -24,4 +24,12 @@ jobs: | |
version: v1.57 | ||
|
||
- name: Test | ||
run: go test -race -v ./... | ||
run: go test -race -covermode atomic -coverprofile=covprofile -v ./... | ||
|
||
- name: Install Goveralls | ||
run: go install github.com/mattn/[email protected] | ||
|
||
- name: Upload Coverage | ||
env: | ||
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: goveralls -ignore=cmd/**/*.go -coverprofile=covprofile -service=github |
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,33 @@ | ||
package brevo | ||
|
||
import ( | ||
"errors" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestNew(t *testing.T) { | ||
_, err := New("", nil) | ||
want := errors.New("brevo API key is blank") | ||
if !cmp.Equal(want.Error(), err.Error()) { | ||
t.Errorf("New(): got=%q want=%q", err, want) | ||
} | ||
} | ||
|
||
type RoundTripFunc func(req *http.Request) *http.Response | ||
|
||
func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { | ||
return f(req), nil | ||
} | ||
|
||
type FaultyRoundTripFunc func(req *http.Request) *http.Response | ||
|
||
func (f FaultyRoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { | ||
return f(req), errors.New("boom baby boom") | ||
} | ||
|
||
func NewTestClient[T RoundTripFunc | FaultyRoundTripFunc](tripper T) (*EmailClient, error) { | ||
return New("key", &http.Client{Transport: http.RoundTripper(tripper)}) | ||
} |
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ import ( | |
"bytes" | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"io" | ||
"log/slog" | ||
"net/http" | ||
|
@@ -55,22 +54,6 @@ func TestEmailHandler_FailedValidation(t *testing.T) { | |
} | ||
} | ||
|
||
type RoundTripFunc func(req *http.Request) *http.Response | ||
|
||
func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { | ||
return f(req), nil | ||
} | ||
|
||
type FaultyRoundTripFunc func(req *http.Request) *http.Response | ||
|
||
func (f FaultyRoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { | ||
return f(req), errors.New("boom baby boom") | ||
} | ||
|
||
func NewTestClient[T RoundTripFunc | FaultyRoundTripFunc](tripper T) (*EmailClient, error) { | ||
return New("key", &http.Client{Transport: http.RoundTripper(tripper)}) | ||
} | ||
|
||
func TestEmailHandler_Success(t *testing.T) { | ||
tripper := func(req *http.Request) *http.Response { | ||
return &http.Response{ | ||
|
@@ -85,6 +68,8 @@ func TestEmailHandler_Success(t *testing.T) { | |
email := emailer.Email{ | ||
From: "[email protected]", | ||
To: []string{"[email protected]"}, | ||
BCC: []string{"[email protected]"}, | ||
CC: []string{"[email protected]"}, | ||
Subject: "sub", | ||
HTMLContent: "html", | ||
} | ||
|