mock qiniu, gihub, artifacts client

This commit is contained in:
tongjingran 2020-07-24 19:24:07 +08:00
parent 8c719effc8
commit dc72708d64
9 changed files with 265 additions and 115 deletions

View File

@ -180,7 +180,7 @@ func doDiffUnderProw(cmd *cobra.Command, args []string) {
} }
qc = qiniu.NewClient(&conf) qc = qiniu.NewClient(&conf)
localArtifacts := qiniu.Artifacts{ localArtifacts := qiniu.ProfileArtifacts{
Directory: artifacts, Directory: artifacts,
ProfileName: newProfile, ProfileName: newProfile,
ChangedProfileName: qiniu.ChangedProfileName, ChangedProfileName: qiniu.ChangedProfileName,

View File

@ -135,6 +135,12 @@ func TestCreateGithubComment(t *testing.T) {
p.CreateGithubComment("", coverList) p.CreateGithubComment("", coverList)
} }
func TestCreateGithubCommentError(t *testing.T) {
p := &GithubPrComment{}
err := p.CreateGithubComment("", cover.DeltaCovList{})
assert.NoError(t, err)
}
func TestGetPrChangedFiles(t *testing.T) { func TestGetPrChangedFiles(t *testing.T) {
client, router, _, teardown := setup() client, router, _, teardown := setup()
defer teardown() defer teardown()
@ -160,3 +166,11 @@ func TestGetPrChangedFiles(t *testing.T) {
assert.Equal(t, err, nil) assert.Equal(t, err, nil)
assert.Equal(t, changedFiles, expectFiles) assert.Equal(t, changedFiles, expectFiles)
} }
func TestGetCommentFlag(t *testing.T) {
p := GithubPrComment{
CommentFlag: "flag",
}
flag := p.GetCommentFlag()
assert.Equal(t, flag, p.CommentFlag)
}

View File

@ -1,24 +1,34 @@
package clients package clients
import "github.com/qiniu/goc/pkg/cover" import (
"github.com/qiniu/goc/pkg/cover"
)
type MockPrComment struct { type MockPrComment struct {
GetPrChangedFilesRes []string
GetPrChangedFilesErr error
PostCommentErr error
EraseHistoryCommentErr error
CreateGithubCommentErr error
CommentFlag string
} }
func (s *MockPrComment) GetPrChangedFiles() (files []string, err error) { func (s *MockPrComment) GetPrChangedFiles() (files []string, err error) {
return nil, nil return s.GetPrChangedFilesRes, s.GetPrChangedFilesErr
} }
func (s *MockPrComment) PostComment(content, commentPrefix string) error { func (s *MockPrComment) PostComment(content, commentPrefix string) error {
return nil return s.PostCommentErr
} }
func (s *MockPrComment) EraseHistoryComment(commentPrefix string) error { func (s *MockPrComment) EraseHistoryComment(commentPrefix string) error {
return nil return s.EraseHistoryCommentErr
} }
func (s *MockPrComment) CreateGithubComment(commentPrefix string, diffCovList cover.DeltaCovList) (err error) { func (s *MockPrComment) CreateGithubComment(commentPrefix string, diffCovList cover.DeltaCovList) (err error) {
return nil return s.CreateGithubCommentErr
} }
func (s *MockPrComment) GetCommentFlag() string { func (s *MockPrComment) GetCommentFlag() string {
return "" return s.CommentFlag
} }

View File

@ -3,32 +3,59 @@ package clients
import ( import (
"context" "context"
"github.com/qiniu/goc/pkg/qiniu" "github.com/qiniu/goc/pkg/qiniu"
"os"
"time" "time"
) )
type MockQnClient struct { type MockQnClient struct {
QiniuObjectHandleRes qiniu.ObjectHandle
ReadObjectRes []byte
ReadObjectErr error
ListAllRes []string
ListAllErr error
GetAccessURLRes string
GetArtifactDetailsRes *qiniu.LogHistoryTemplate
GetArtifactDetailsErr error
ListSubDirsRes []string
ListSubDirsErr error
} }
func (s *MockQnClient) QiniuObjectHandle(key string) qiniu.ObjectHandle { func (s *MockQnClient) QiniuObjectHandle(key string) qiniu.ObjectHandle {
return nil return s.QiniuObjectHandleRes
} }
func (s *MockQnClient) ReadObject(key string) ([]byte, error) { func (s *MockQnClient) ReadObject(key string) ([]byte, error) {
return nil, nil return s.ReadObjectRes, s.ReadObjectErr
} }
func (s *MockQnClient) ListAll(ctx context.Context, prefix string, delimiter string) ([]string, error) { func (s *MockQnClient) ListAll(ctx context.Context, prefix string, delimiter string) ([]string, error) {
return nil, nil return s.ListAllRes, s.ListAllErr
} }
func (s *MockQnClient) GetAccessURL(key string, timeout time.Duration) string { func (s *MockQnClient) GetAccessURL(key string, timeout time.Duration) string {
return "" return s.GetAccessURLRes
} }
func (s *MockQnClient) GetArtifactDetails(key string) (*qiniu.LogHistoryTemplate, error) { func (s *MockQnClient) GetArtifactDetails(key string) (*qiniu.LogHistoryTemplate, error) {
return nil, nil return s.GetArtifactDetailsRes, s.GetArtifactDetailsErr
} }
func (s *MockQnClient) ListSubDirs(prefix string) ([]string, error) { func (s *MockQnClient) ListSubDirs(prefix string) ([]string, error) {
return nil, nil return s.ListSubDirsRes, s.ListSubDirsErr
}
type MockArtifacts struct {
ProfilePathRes string
CreateChangedProfileRes *os.File
GetChangedProfileNameRes string
}
func (s *MockArtifacts) ProfilePath() string {
return s.ProfilePathRes
}
func (s *MockArtifacts) CreateChangedProfile() *os.File {
return s.CreateChangedProfileRes
}
func (s *MockArtifacts) GetChangedProfileName() string {
return s.GetChangedProfileNameRes
} }

View File

@ -55,7 +55,7 @@ type Job struct {
CovThreshold int CovThreshold int
LocalProfilePath string LocalProfilePath string
QiniuClient qiniu.Client QiniuClient qiniu.Client
LocalArtifacts *qiniu.Artifacts LocalArtifacts qiniu.Artifacts
GithubComment github.PrComment GithubComment github.PrComment
FullDiff bool FullDiff bool
} }
@ -70,16 +70,13 @@ func (j *Job) RunPresubmit() error {
// step1: get local profile cov // step1: get local profile cov
localP, err := cover.ReadFileToCoverList(j.LocalProfilePath) localP, err := cover.ReadFileToCoverList(j.LocalProfilePath)
if err != nil { if err != nil {
logrus.Errorf("failed to get remote cover profile: %s", err.Error()) return fmt.Errorf("failed to get remote cover profile: %s", err.Error())
return err
} }
logrus.Warnf("localP: [%+v]", localP)
//step2: find the remote healthy cover profile from qiniu bucket //step2: find the remote healthy cover profile from qiniu bucket
remoteProfile, err := qiniu.FindBaseProfileFromQiniu(j.QiniuClient, j.PostSubmitJob, j.PostSubmitCoverProfile) remoteProfile, err := qiniu.FindBaseProfileFromQiniu(j.QiniuClient, j.PostSubmitJob, j.PostSubmitCoverProfile)
if err != nil { if err != nil {
logrus.Errorf("failed to get remote cover profile: %s", err.Error()) return fmt.Errorf("failed to get remote cover profile: %s", err.Error())
return err
} }
if remoteProfile == nil { if remoteProfile == nil {
logrus.Infof("get non healthy remoteProfile, do nothing") logrus.Infof("get non healthy remoteProfile, do nothing")
@ -87,31 +84,27 @@ func (j *Job) RunPresubmit() error {
} }
baseP, err := cover.CovList(bytes.NewReader(remoteProfile)) baseP, err := cover.CovList(bytes.NewReader(remoteProfile))
if err != nil { if err != nil {
logrus.Errorf("failed to get remote cover profile: %s", err.Error()) return fmt.Errorf("failed to get remote cover profile: %s", err.Error())
return err
} }
logrus.Warnf("baseP: [%+v]", baseP)
// step3: get github pull request changed files' name and calculate diff cov between local and remote profile // step3: get github pull request changed files' name and calculate diff cov between local and remote profile
changedFiles, deltaCovList, err := getFilesAndCovList(j.FullDiff, j.GithubComment, localP, baseP) changedFiles, deltaCovList, err := getFilesAndCovList(j.FullDiff, j.GithubComment, localP, baseP)
if err != nil { if err != nil {
logrus.Errorf("Get files and covlist failed: %s", err.Error()) return fmt.Errorf("Get files and covlist failed: %s", err.Error())
return err
} }
// step4: generate changed file html coverage // step4: generate changed file html coverage
err = j.WriteChangedCov(changedFiles) err = j.WriteChangedCov(changedFiles)
if err != nil { if err != nil {
logrus.WithError(err).Fatalf("filter local profile to %s with changed files failed", j.LocalArtifacts.ChangedProfileName) return fmt.Errorf("filter local profile to %s with changed files failed: %s", j.LocalArtifacts.GetChangedProfileName(), err.Error())
} }
err = j.CreateChangedCovHtml() err = j.CreateChangedCovHtml()
if err != nil { if err != nil {
logrus.WithError(err).Fatalf("create changed file related coverage html failed") return fmt.Errorf("create changed file related coverage html failed: %s", err.Error())
} }
j.SetDeltaCovLinks(deltaCovList) j.SetDeltaCovLinks(deltaCovList)
// step6: post comment to github // step5: post comment to github
commentPrefix := github.CommentsPrefix commentPrefix := github.CommentsPrefix
if j.GithubComment.GetCommentFlag() != "" { if j.GithubComment.GetCommentFlag() != "" {
commentPrefix = fmt.Sprintf("**%s** ", j.GithubComment.GetCommentFlag()) + commentPrefix commentPrefix = fmt.Sprintf("**%s** ", j.GithubComment.GetCommentFlag()) + commentPrefix
@ -122,7 +115,7 @@ func (j *Job) RunPresubmit() error {
} }
err = j.GithubComment.CreateGithubComment(commentPrefix, deltaCovList) err = j.GithubComment.CreateGithubComment(commentPrefix, deltaCovList)
if err != nil { if err != nil {
logrus.WithError(err).Fatalf("Post comment to github failed.") return fmt.Errorf("Post comment to github failed: %s", err.Error())
} }
return nil return nil
@ -202,10 +195,10 @@ func (j *Job) SetDeltaCovLinks(c cover.DeltaCovList) {
// CreateChangedCovHtml create changed file related coverage html base on the local artifact // CreateChangedCovHtml create changed file related coverage html base on the local artifact
func (j *Job) CreateChangedCovHtml() error { func (j *Job) CreateChangedCovHtml() error {
if j.LocalArtifacts.ChangedProfileName == "" { if j.LocalArtifacts.GetChangedProfileName() == "" {
logrus.Errorf("param LocalArtifacts.ChangedProfileName is empty") logrus.Errorf("param LocalArtifacts.ChangedProfileName is empty")
} }
pathProfileCov := j.LocalArtifacts.ChangedProfileName pathProfileCov := j.LocalArtifacts.GetChangedProfileName()
pathHtmlCov := path.Join(os.Getenv("ARTIFACTS"), j.HtmlProfile()) pathHtmlCov := path.Join(os.Getenv("ARTIFACTS"), j.HtmlProfile())
cmdTxt := fmt.Sprintf("go tool cover -html=%s -o %s", pathProfileCov, pathHtmlCov) cmdTxt := fmt.Sprintf("go tool cover -html=%s -o %s", pathProfileCov, pathHtmlCov)
logrus.Printf("Running command '%s'\n", cmdTxt) logrus.Printf("Running command '%s'\n", cmdTxt)

View File

@ -18,6 +18,8 @@ package prow
import ( import (
"errors" "errors"
"fmt"
"github.com/qiniu/goc/pkg/cover"
"github.com/qiniu/goc/pkg/github" "github.com/qiniu/goc/pkg/github"
"github.com/qiniu/goc/pkg/mock/clients" "github.com/qiniu/goc/pkg/mock/clients"
"github.com/qiniu/goc/pkg/qiniu" "github.com/qiniu/goc/pkg/qiniu"
@ -36,6 +38,7 @@ qiniu.com/kodo/bd/bdgetter/source.go:37.34,39.2 1 0
qiniu.com/kodo/bd/pfd/locker/app/qboxbdlocker/main.go:50.2,53.52 4 1 qiniu.com/kodo/bd/pfd/locker/app/qboxbdlocker/main.go:50.2,53.52 4 1
qiniu.com/kodo/bd/pfd/locker/bdlocker/locker.go:33.51,35.2 1 0` qiniu.com/kodo/bd/pfd/locker/bdlocker/locker.go:33.51,35.2 1 0`
defaultLocalPath = "local.cov" defaultLocalPath = "local.cov"
defaultChangedPath = "changed.cov"
) )
func TestTrimGhFileToProfile(t *testing.T) { func TestTrimGhFileToProfile(t *testing.T) {
@ -76,7 +79,7 @@ qiniu.com/kodo/bd/pfd/locker/bdlocker/locker.go:33.51,35.2 1 0
defer os.Remove(savePath) defer os.Remove(savePath)
j := &Job{ j := &Job{
LocalProfilePath: path, LocalProfilePath: path,
LocalArtifacts: &qiniu.Artifacts{ChangedProfileName: savePath}, LocalArtifacts: &qiniu.ProfileArtifacts{ChangedProfileName: savePath},
} }
j.WriteChangedCov(changedFiles) j.WriteChangedCov(changedFiles)
@ -133,7 +136,7 @@ func TestRunPresubmitFulldiff(t *testing.T) {
PostSubmitJob: "kodo-postsubmits-go-st-coverage", PostSubmitJob: "kodo-postsubmits-go-st-coverage",
PostSubmitCoverProfile: "filterd.cov", PostSubmitCoverProfile: "filterd.cov",
LocalProfilePath: localPath, LocalProfilePath: localPath,
LocalArtifacts: &qiniu.Artifacts{ChangedProfileName: ChangedProfilePath}, LocalArtifacts: &qiniu.ProfileArtifacts{ChangedProfileName: ChangedProfilePath},
QiniuClient: qc, QiniuClient: qc,
GithubComment: prClient, GithubComment: prClient,
FullDiff: true, FullDiff: true,
@ -144,44 +147,60 @@ func TestRunPresubmitFulldiff(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
} }
func TestRunPresubmitErrorGetRemoteCoverProfile(t *testing.T) { func TestRunPresubmitError(t *testing.T) {
j := &Job{ items := []struct {
prepare bool // 是否需要准备本地cov
j Job
err string
}{
{
prepare: false,
j: Job{
LocalProfilePath: "unkown", LocalProfilePath: "unkown",
} },
err := j.RunPresubmit() err: "no such file or directory",
assert.Contains(t, err.Error(), "no such file or directory") },
} {
prepare: true,
func TestRunPresubmitGetEmptyProfile(t *testing.T) { j: Job{
path := "local.cov" LocalProfilePath: defaultLocalPath,
setup(path, defaultContent)
defer os.Remove(path)
j := &Job{
LocalProfilePath: path,
QiniuClient: &clients.MockQnClient{}, QiniuClient: &clients.MockQnClient{},
},
},
{
prepare: true,
j: Job{
LocalProfilePath: defaultLocalPath,
QiniuClient: &clients.MockQnClient{ListSubDirsErr: errors.New("mock error")},
},
err: "mock error",
},
{
prepare: true,
j: Job{
LocalProfilePath: defaultLocalPath,
QiniuClient: &MockProfileQnClient{},
GithubComment: &clients.MockPrComment{GetPrChangedFilesRes: []string{"qiniu.com/kodo/apiserver/server/main.go"}},
FullDiff: true,
LocalArtifacts: &qiniu.ProfileArtifacts{ChangedProfileName: defaultChangedPath},
},
err: "",
},
} }
err := j.RunPresubmit() for _, tc := range items {
assert.NoError(t, err) if tc.prepare {
} path := defaultLocalPath
type MockErrorListSubDirsQnClient struct {
*clients.MockQnClient
}
func (s *MockErrorListSubDirsQnClient) ListSubDirs(prefix string) ([]string, error) {
return nil, errors.New("mock error")
}
func TestRunPresubmitErrorGetBaseProfile(t *testing.T) {
path := "local.cov"
setup(path, defaultContent) setup(path, defaultContent)
defer os.Remove(path) defer os.Remove(path)
j := &Job{ defer os.Remove(defaultChangedPath)
LocalProfilePath: path, }
QiniuClient: &MockErrorListSubDirsQnClient{}, err := tc.j.RunPresubmit()
if tc.err == "" {
assert.NoError(t, err)
} else {
assert.Contains(t, err.Error(), tc.err)
}
} }
err := j.RunPresubmit()
assert.Contains(t, err.Error(), "mock error")
} }
type MockProfileQnClient struct { type MockProfileQnClient struct {
@ -189,7 +208,7 @@ type MockProfileQnClient struct {
} }
func (s *MockProfileQnClient) ListSubDirs(prefix string) ([]string, error) { func (s *MockProfileQnClient) ListSubDirs(prefix string) ([]string, error) {
return []string{"1"}, nil return []string{defaultContent}, nil
} }
func (s *MockProfileQnClient) ReadObject(key string) ([]byte, error) { func (s *MockProfileQnClient) ReadObject(key string) ([]byte, error) {
@ -200,43 +219,93 @@ func (s *MockProfileQnClient) ReadObject(key string) ([]byte, error) {
return []byte(""), nil return []byte(""), nil
} }
// 无法实现coverList报错 func TestGetFilesAndCovList(t *testing.T) {
//func TestRunPresubmitErrorReadBaseProfile(t *testing.T) { items := []struct {
// path := "local.cov" fullDiff bool
// setup(path, defaultContent) prComment github.PrComment
// defer os.Remove(path) localP cover.CoverageList
// j := &Job{ baseP cover.CoverageList
// LocalProfilePath: path, err string
// QiniuClient: &MockProfileQnClient{}, lenFiles int
// } lenCovList int
// err := j.RunPresubmit() }{
// assert.Contains(t, err.Error(), "mock error") {
//} fullDiff: true,
prComment: &clients.MockPrComment{},
localP: cover.CoverageList{
{FileName: "qiniu.com/kodo/apiserver/server/main.go", NCoveredStmts: 2, NAllStmts: 2},
{FileName: "qiniu.com/kodo/apiserver/server/test.go", NCoveredStmts: 2, NAllStmts: 2},
},
baseP: cover.CoverageList{
{FileName: "qiniu.com/kodo/apiserver/server/main.go", NCoveredStmts: 1, NAllStmts: 2},
{FileName: "qiniu.com/kodo/apiserver/server/test.go", NCoveredStmts: 1, NAllStmts: 2},
},
lenFiles: 2,
lenCovList: 2,
},
{
fullDiff: false,
prComment: &clients.MockPrComment{GetPrChangedFilesErr: errors.New("mock error")},
err: "mock error",
},
{
fullDiff: false,
prComment: &clients.MockPrComment{},
lenFiles: 0,
lenCovList: 0,
},
{
fullDiff: false,
prComment: &clients.MockPrComment{GetPrChangedFilesRes: []string{"qiniu.com/kodo/apiserver/server/main.go"}},
localP: cover.CoverageList{
{FileName: "qiniu.com/kodo/apiserver/server/main.go", NCoveredStmts: 2, NAllStmts: 2},
{FileName: "qiniu.com/kodo/apiserver/server/test.go", NCoveredStmts: 2, NAllStmts: 2},
},
baseP: cover.CoverageList{
{FileName: "qiniu.com/kodo/apiserver/server/main.go", NCoveredStmts: 1, NAllStmts: 2},
{FileName: "qiniu.com/kodo/apiserver/server/test.go", NCoveredStmts: 1, NAllStmts: 2},
},
lenFiles: 1,
lenCovList: 1,
},
}
//type MockErrorPrComment struct { for i, tc := range items {
// *clients.MockPrComment fmt.Println(i)
//} files, covList, err := getFilesAndCovList(tc.fullDiff, tc.prComment, tc.localP, tc.baseP)
// if err != nil {
//func (s *MockErrorPrComment) GetPrChangedFiles() (files []string, err error) { assert.Equal(t, err.Error(), tc.err)
// return []string{"aaa"}, nil } else {
//} assert.Equal(t, len(files), tc.lenFiles)
// assert.Equal(t, len(covList), tc.lenCovList)
//func TestGetFilesAndCovList(t *testing.T){ }
// items := []struct { }
// fullDiff bool }
// prComment github.PrComment
// localP cover.CoverageList func TestSetDeltaCovLinks(t *testing.T) {
// baseP cover.CoverageList covList := cover.DeltaCovList{{FileName: "file1", BasePer: "5%", NewPer: "5%", DeltaPer: "0"}}
// }{ j := &Job{
// { QiniuClient: &clients.MockQnClient{},
// inputFiles: []string{"src/qiniu.com/kodo/io/io/io_svr.go", "README.md"}, }
// expectFiles: []string{"qiniu.com/kodo/io/io/io_svr.go", "README.md"}, j.SetDeltaCovLinks(covList)
// }, }
// }
// // functions to be done
// for _, tc := range items {
// f := trimGhFileToProfile(tc.inputFiles) func TestRunPostsubmit(t *testing.T) {
// assert.Equal(t, f, tc.expectFiles) j := &Job{}
// } err := j.RunPostsubmit()
// getFilesAndCovList assert.NoError(t, err)
//} }
func TestRunPeriodic(t *testing.T) {
j := &Job{}
err := j.RunPeriodic()
assert.NoError(t, err)
}
func TestFetch(t *testing.T) {
j := &Job{}
res := j.Fetch("buidID", "name")
assert.Equal(t, res, []byte{})
}

View File

@ -58,7 +58,7 @@ type QnClient struct {
BucketManager *storage.BucketManager BucketManager *storage.BucketManager
} }
// NewQnClient creates a new QnClient to work with qiniu cloud // NewClient creates a new QnClient to work with qiniu cloud
func NewClient(cfg *Config) *QnClient { func NewClient(cfg *Config) *QnClient {
return &QnClient{ return &QnClient{
cfg: cfg, cfg: cfg,

View File

@ -107,20 +107,26 @@ func FindBaseProfileFromQiniu(qc Client, prowJobName, covProfileName string) ([]
return qc.ReadObject(profilePath) return qc.ReadObject(profilePath)
} }
// Artifacts prepresents the rule to store test artifacts in prow type Artifacts interface {
type Artifacts struct { ProfilePath() string
CreateChangedProfile() *os.File
GetChangedProfileName() string
}
// ProfileArtifacts prepresents the rule to store test artifacts in prow
type ProfileArtifacts struct {
Directory string Directory string
ProfileName string ProfileName string
ChangedProfileName string // create temporary to save changed file related coverage profile ChangedProfileName string // create temporary to save changed file related coverage profile
} }
// ProfilePath returns a full path for profile // ProfilePath returns a full path for profile
func (a *Artifacts) ProfilePath() string { func (a *ProfileArtifacts) ProfilePath() string {
return path.Join(a.Directory, a.ProfileName) return path.Join(a.Directory, a.ProfileName)
} }
// CreateChangedProfile creates a profile in order to store the most related files based on Github Pull Request // CreateChangedProfile creates a profile in order to store the most related files based on Github Pull Request
func (a *Artifacts) CreateChangedProfile() *os.File { func (a *ProfileArtifacts) CreateChangedProfile() *os.File {
if a.ChangedProfileName == "" { if a.ChangedProfileName == "" {
log.Fatalf("param Artifacts.ChangedProfileName should not be empty") log.Fatalf("param Artifacts.ChangedProfileName should not be empty")
} }
@ -132,3 +138,7 @@ func (a *Artifacts) CreateChangedProfile() *os.File {
return p return p
} }
func (a *ProfileArtifacts) GetChangedProfileName() string {
return a.ChangedProfileName
}

View File

@ -20,6 +20,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"os"
) )
func TestFindBaseProfileFromQiniu(t *testing.T) { func TestFindBaseProfileFromQiniu(t *testing.T) {
@ -39,3 +40,29 @@ func TestFindBaseProfileFromQiniu(t *testing.T) {
assert.Equal(t, err, nil) assert.Equal(t, err, nil)
assert.Equal(t, string(getProfile), mockProfileContent) assert.Equal(t, string(getProfile), mockProfileContent)
} }
func TestArtifacts_ProfilePath(t *testing.T) {
p := &ProfileArtifacts{
Directory: "directory/",
ProfileName: "profile",
}
profilePath := p.ProfilePath()
assert.Equal(t, profilePath, "directory/profile")
}
func TestProfileArtifacts_CreateChangedProfile(t *testing.T) {
p := &ProfileArtifacts{
ChangedProfileName: "test.cov",
}
file := p.CreateChangedProfile()
defer file.Close()
defer os.Remove(p.ChangedProfileName)
}
func TestProfileArtifacts_GetChangedProfileName(t *testing.T) {
p := &ProfileArtifacts{
ChangedProfileName: "change.cov",
}
name := p.GetChangedProfileName()
assert.Equal(t, name, "change.cov")
}