forked from vitessio/vitess
/
ui.go
40 lines (31 loc) · 1.04 KB
/
ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package topovalidator
import (
"fmt"
"golang.org/x/net/context"
"github.com/youtube/vitess/go/vt/topo"
)
// This file contains the UITest validator. It doesn't do anything,
// but create a Fixer with a couple actions, to test the UI.
// RegisterUITestValidator registers the UITest Validator.
func RegisterUITestValidator() {
RegisterValidator("UITest Validator", &UITestValidator{})
}
// UITestValidator implements Validator.
type UITestValidator struct{}
// Audit is part of the Validator interface.
func (kv *UITestValidator) Audit(ctx context.Context, ts topo.Server, w *Workflow) error {
w.AddFixer("UITest Fixer", "UI Test Fixer", &UITestFixer{}, []string{"Success", "Error"})
return nil
}
// UITestFixer implements Fixer.
type UITestFixer struct{}
// Action is part of the Fixer interface.
func (kf *UITestFixer) Action(ctx context.Context, name string) error {
if name == "Success" {
return nil
}
if name == "Error" {
return fmt.Errorf("oh no, you pressed the Error button")
}
return fmt.Errorf("unknown UITestFixer action: %v", name)
}