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

plan: test, which illustrate "return nil, err" problem #336

Merged
merged 4 commits into from
Oct 4, 2016

Conversation

avnik
Copy link
Contributor

@avnik avnik commented Sep 30, 2016

No description provided.

Copy link
Contributor

@rebeccaskinner rebeccaskinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test scenario seems good; we should probably keep the test unmerged and rebase after the module API changes since AFAIK they should fix this.

Status string
Level resource.StatusLevel
Error error
NilAndError bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would make more sense to have a type NilTask struct that just returns nil, error to keep the code clean

@avnik
Copy link
Contributor Author

avnik commented Oct 3, 2016

@rebeccaskinner I add commit with fix, ad can rework test, if you or @BrianHicks prefer it.

This fix need to be merged before lvm branch

@@ -108,6 +108,11 @@ func (g *pipelineGen) PlanNode(taski interface{}) (interface{}, error) {
}
status, err := twrapper.Task.Check(renderer)

// create empty Status structure, if it not created in .Check()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use this pr, we probably need the same check in apply/pipeline.go. That is where I am panicking in #343

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryane Will do, so don't panic ;)

return nil, errors.New("apply error")
}

// NilAndError return a FakeTask that will simulate `return nil, err` cawe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case


require.NoError(t, g.Validate())

// applying should return error, and not panicking
Copy link
Contributor

@ryane ryane Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Apply should return an error and not panic

@@ -105,6 +105,20 @@ func TestApplyStillChange(t *testing.T) {
}
}

func TestApplyNilError(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments on exported methods (will fix cc issues)

@@ -45,6 +45,21 @@ func TestPlanNoOp(t *testing.T) {
assert.Equal(t, task, result.Task)
}

func TestPlanNilAndError(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments on exported methods

@@ -65,6 +65,25 @@ func WillChange() *FakeTask {
}
}

// Task which always return (nil, error) tuple
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avnik avnik force-pushed the bug/return-nil-err branch 2 times, most recently from a73ec6b to 0a1ffed Compare October 4, 2016 01:38
@avnik avnik changed the title [WIP] plan: test, which illustrate "return nil, err" problem plan: test, which illustrate "return nil, err" problem Oct 4, 2016
@avnik
Copy link
Contributor Author

avnik commented Oct 4, 2016

@rebeccaskinner @ryane all test are green now.
If Brian offer better fix, we can revert commit with my fixups, and leave tests only.

@rebeccaskinner rebeccaskinner merged commit 82a2425 into master Oct 4, 2016
@rebeccaskinner rebeccaskinner deleted the bug/return-nil-err branch October 4, 2016 22:07
BrianHicks pushed a commit that referenced this pull request Dec 22, 2016
plan: test, which illustrate "return nil, err" problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants