Skip to content

Commit

Permalink
Fixed few review comments and rebase the branch
Browse files Browse the repository at this point in the history
Signed-off-by: parauliya <[email protected]>
  • Loading branch information
parauliya committed Apr 21, 2021
1 parent b217be8 commit c5fbe14
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions grpc-server/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/tinkerbell/tink/db/mock"
tb "github.com/tinkerbell/tink/protos/template"
pb "github.com/tinkerbell/tink/protos/template"
)

const (
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestCreateTemplate(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()
s := testServer(t, tc.args.db)
res, err := s.CreateTemplate(ctx, &tb.WorkflowTemplate{Name: tc.args.name, Data: tc.args.template})
res, err := s.CreateTemplate(ctx, &pb.WorkflowTemplate{Name: tc.args.name, Data: tc.args.template})
if tc.want.expectedError {
assert.Error(t, err)
} else {
Expand All @@ -157,7 +157,7 @@ func TestGetTemplate(t *testing.T) {
type (
args struct {
db mock.DB
getRequest *tb.GetRequest
getRequest *pb.GetRequest
}
)
testCases := map[string]struct {
Expand All @@ -173,24 +173,24 @@ func TestGetTemplate(t *testing.T) {
TemplateDB: map[string]interface{}{
templateName1: template1,
},
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*tb.WorkflowTemplate, error) {
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*pb.WorkflowTemplate, error) {
t.Log("in get template func")

if fields["id"] == templateID1 || fields["name"] == templateName1 {
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateID1,
Name: templateName1,
Data: template1,
}, nil
}
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateNotFoundID,
Name: templateNotFoundName,
Data: templateNotFoundTemplate,
}, errors.New("failed to get template")
},
},
getRequest: &tb.GetRequest{GetBy: &tb.GetRequest_Name{Name: templateName1}},
getRequest: &pb.GetRequest{GetBy: &pb.GetRequest_Name{Name: templateName1}},
},
id: templateID1,
name: templateName1,
Expand All @@ -204,24 +204,24 @@ func TestGetTemplate(t *testing.T) {
TemplateDB: map[string]interface{}{
templateName1: template1,
},
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*tb.WorkflowTemplate, error) {
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*pb.WorkflowTemplate, error) {
t.Log("in get template func")

if fields["id"] == templateID1 || fields["name"] == templateName1 {
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateID1,
Name: templateName1,
Data: template1,
}, nil
}
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateNotFoundID,
Name: templateNotFoundName,
Data: templateNotFoundTemplate,
}, errors.New("failed to get template")
},
},
getRequest: &tb.GetRequest{GetBy: &tb.GetRequest_Name{Name: templateName2}},
getRequest: &pb.GetRequest{GetBy: &pb.GetRequest_Name{Name: templateName2}},
},
id: templateNotFoundID,
name: templateNotFoundName,
Expand All @@ -235,24 +235,24 @@ func TestGetTemplate(t *testing.T) {
TemplateDB: map[string]interface{}{
templateName1: template1,
},
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*tb.WorkflowTemplate, error) {
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*pb.WorkflowTemplate, error) {
t.Log("in get template func")

if fields["id"] == templateID1 || fields["name"] == templateName1 {
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateID1,
Name: templateName1,
Data: template1,
}, nil
}
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateNotFoundID,
Name: templateNotFoundName,
Data: templateNotFoundTemplate,
}, errors.New("failed to get template")
},
},
getRequest: &tb.GetRequest{GetBy: &tb.GetRequest_Id{Id: templateID1}},
getRequest: &pb.GetRequest{GetBy: &pb.GetRequest_Id{Id: templateID1}},
},
id: templateID1,
name: templateName1,
Expand All @@ -266,24 +266,24 @@ func TestGetTemplate(t *testing.T) {
TemplateDB: map[string]interface{}{
templateName1: template1,
},
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*tb.WorkflowTemplate, error) {
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*pb.WorkflowTemplate, error) {
t.Log("in get template func")

if fields["id"] == templateID1 || fields["name"] == templateName1 {
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateID1,
Name: templateName1,
Data: template1,
}, nil
}
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateNotFoundID,
Name: templateNotFoundName,
Data: templateNotFoundTemplate,
}, errors.New("failed to get template")
},
},
getRequest: &tb.GetRequest{GetBy: &tb.GetRequest_Id{Id: templateID2}},
getRequest: &pb.GetRequest{GetBy: &pb.GetRequest_Id{Id: templateID2}},
},
id: templateNotFoundID,
name: templateNotFoundName,
Expand All @@ -297,24 +297,24 @@ func TestGetTemplate(t *testing.T) {
TemplateDB: map[string]interface{}{
templateName1: template1,
},
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*tb.WorkflowTemplate, error) {
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*pb.WorkflowTemplate, error) {
t.Log("in get template func")

if fields["id"] == templateID1 || fields["name"] == templateName1 {
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateID1,
Name: templateName1,
Data: template1,
}, nil
}
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateNotFoundID,
Name: templateNotFoundName,
Data: templateNotFoundTemplate,
}, errors.New("failed to get template")
},
},
getRequest: &tb.GetRequest{},
getRequest: &pb.GetRequest{},
},
id: templateNotFoundID,
name: templateNotFoundName,
Expand All @@ -328,17 +328,17 @@ func TestGetTemplate(t *testing.T) {
TemplateDB: map[string]interface{}{
templateName1: template1,
},
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*tb.WorkflowTemplate, error) {
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (*pb.WorkflowTemplate, error) {
t.Log("in get template func")

if fields["id"] == templateID1 || fields["name"] == templateName1 {
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateID1,
Name: templateName1,
Data: template1,
}, nil
}
return &tb.WorkflowTemplate{
return &pb.WorkflowTemplate{
Id: templateNotFoundID,
Name: templateNotFoundName,
Data: templateNotFoundTemplate,
Expand Down

0 comments on commit c5fbe14

Please sign in to comment.