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

Make hooks test validation work as expected #782

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
16 changes: 8 additions & 8 deletions validation/hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ func main() {
util.WaitingForStatus(*r, util.LifecycleStatusStopped, time.Second*10, time.Second)
return nil
},
PostDelete: func(r *util.Runtime) error {
outputData, err := os.ReadFile(output)
if err != nil || string(outputData) != "pre-start1 called\npre-start2 called\npost-start1 called\npost-start2 called\npost-stop1 called\npost-stop2 called\n" {
return fmt.Errorf("%v\n%v", specerror.NewError(specerror.PosixHooksCalledInOrder, fmt.Errorf("Hooks MUST be called in the listed order"), rspec.Version), specerror.NewError(specerror.ProcImplement, fmt.Errorf("The runtime MUST run the user-specified program, as specified by `process`"), rspec.Version))
}
return nil
},
}

err := util.RuntimeLifecycleValidate(config)
outputData, _ := os.ReadFile(output)
if err == nil && string(outputData) != "pre-start1 called\npre-start2 called\npost-start1\npost-start2\npost-stop1\npost-stop2\n" {
err = specerror.NewError(specerror.PosixHooksCalledInOrder, fmt.Errorf("Hooks MUST be called in the listed order"), rspec.Version)
diagnostic := map[string]string{
"error": err.Error(),
}
_ = t.YAML(diagnostic)
} else {
if err != nil {
diagnostic := map[string]string{
"error": err.Error(),
}
Expand Down