Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ineffective assignment in db/mock/template.go #511

Merged
merged 2 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions db/mock/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Template struct {
}

// CreateTemplate creates a new workflow template
func (d DB) CreateTemplate(ctx context.Context, name string, data string, id uuid.UUID) error {
func (d *DB) CreateTemplate(ctx context.Context, name string, data string, id uuid.UUID) error {
if d.TemplateDB == nil {
d.TemplateDB = make(map[string]interface{})
}
Expand Down Expand Up @@ -66,6 +66,6 @@ func (d DB) UpdateTemplate(ctx context.Context, name string, data string, id uui
}

// ClearTemplateDB clear all the templates
func (d DB) ClearTemplateDB() {
func (d *DB) ClearTemplateDB() {
d.TemplateDB = make(map[string]interface{})
}
24 changes: 12 additions & 12 deletions grpc-server/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ tasks:
func TestCreateTemplate(t *testing.T) {
type (
args struct {
db mock.DB
db *mock.DB
name string
template string
}
Expand All @@ -68,7 +68,7 @@ func TestCreateTemplate(t *testing.T) {
}{
"SuccessfulTemplateCreation": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: make(map[string]interface{}),
},
name: "template_1",
Expand All @@ -81,7 +81,7 @@ func TestCreateTemplate(t *testing.T) {

"SuccessfulMultipleTemplateCreation": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
"template_1": mock.Template{
Data: template1,
Expand All @@ -99,7 +99,7 @@ func TestCreateTemplate(t *testing.T) {

"FailedMultipleTemplateCreationWithSameName": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
"template_1": mock.Template{
Data: template1,
Expand All @@ -117,7 +117,7 @@ func TestCreateTemplate(t *testing.T) {

"SuccessfulTemplateCreationAfterDeletingWithSameName": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
"template_1": mock.Template{
Data: template1,
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestCreateTemplate(t *testing.T) {
func TestGetTemplate(t *testing.T) {
type (
args struct {
db mock.DB
db *mock.DB
getRequest *pb.GetRequest
}
)
Expand All @@ -169,7 +169,7 @@ func TestGetTemplate(t *testing.T) {
}{
"SuccessfulTemplateGet_Name": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
templateName1: template1,
},
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestGetTemplate(t *testing.T) {

"FailedTemplateGet_Name": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
templateName1: template1,
},
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestGetTemplate(t *testing.T) {

"SuccessfulTemplateGet_ID": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
templateName1: template1,
},
Expand Down Expand Up @@ -262,7 +262,7 @@ func TestGetTemplate(t *testing.T) {

"FailedTemplateGet_ID": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
templateName1: template1,
},
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestGetTemplate(t *testing.T) {

"FailedTemplateGet_EmptyRequest": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
templateName1: template1,
},
Expand Down Expand Up @@ -324,7 +324,7 @@ func TestGetTemplate(t *testing.T) {

"FailedTemplateGet_NilRequest": {
args: args{
db: mock.DB{
db: &mock.DB{
TemplateDB: map[string]interface{}{
templateName1: template1,
},
Expand Down
Loading