Skip to content

Commit

Permalink
add livetest makefile cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianPy committed Sep 23, 2022
1 parent d137ffa commit e1836e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ licenser:

test:
go test -v ./...

livetest:
rm -f ./internal/changelog/testdata/fixtures/*
rm -f ./internal/github/testdata/fixtures/*
go test -v ./...
25 changes: 5 additions & 20 deletions internal/changelog/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package changelog_test

import (
"context"
"flag"
"testing"

"github.com/elastic/elastic-agent-changelog-tool/internal/changelog"
Expand All @@ -17,23 +16,6 @@ import (
"github.com/stretchr/testify/require"
)

var (
fs = afero.NewMemMapFs()
apiLive = flag.Bool("live", false, "used to live test the Github API")
)

func getGithubAPIByFlag(t *testing.T, live bool) (*github.Client, func() error) {
if *apiLive == true {
hc, err := github.GetHTTPClient(fs)
require.NoError(t, err)
return github.NewClient(hc), func() error { return nil }
}

r, hc := githubtest.GetHttpClient(t)

return github.NewClient(hc), r.Stop
}

func TestBuilder_Build(t *testing.T) {
fs := afero.NewCopyOnWriteFs(afero.NewOsFs(), afero.NewMemMapFs())
viper.Set("fragment_location", "testdata")
Expand All @@ -42,15 +24,18 @@ func TestBuilder_Build(t *testing.T) {

err := b.Build("elastic", "beats")
require.NoError(t, err)

// FIXME: built changelog is not inspectable as b.changelog is not updated &
// there is no way to access it anyway
// fmt.Println(b.Changelog())
// require.Len(t, b.Changelog().Entries, 10)
}

func TestFillEmptyPRField(t *testing.T) {
c, stop := getGithubAPIByFlag(t, *apiLive)
defer stop() //nolint:errcheck
r, hc := githubtest.GetHttpClient(t)
defer r.Stop() //nolint:errcheck

c := github.NewClient(hc)

prIDs, err := changelog.FillEmptyPRField("fe25c73907336fc462d5e6e059d3cd86512484fe", "elastic", "beats", c)
require.NoError(t, err)
Expand Down

0 comments on commit e1836e7

Please sign in to comment.