-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#12 add mockery, add more code to the builder and compiler
- Loading branch information
1 parent
81e97d2
commit 3d8f5af
Showing
9 changed files
with
222 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
quiet: False | ||
keeptree: True | ||
disable-version-string: True | ||
with-expecter: True | ||
mockname: "{{.InterfaceName}}" | ||
filename: "{{.MockName}}.go" | ||
outpkg: mocks | ||
packages: | ||
waffle/internal/rule: | ||
interfaces: | ||
Builder: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package rule | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestCustomCompiler_Compile(t *testing.T) { | ||
type fields struct { | ||
builder Builder | ||
} | ||
type args struct { | ||
name string | ||
value string | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
want *Predicate | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "empty name, error returned", | ||
args: args{ | ||
name: "", | ||
value: "p => p", | ||
}, | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "empty value, error returned", | ||
args: args{ | ||
name: "name", | ||
value: "", | ||
}, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
c := &CustomCompiler{ | ||
builder: tt.fields.builder, | ||
} | ||
got, err := c.Compile(tt.args.name, tt.args.value) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("Compile() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("Compile() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
package rule | ||
|
||
type PredicateLogicalExpression func(payload []byte) (bool, error) | ||
|
||
type Predicate struct { | ||
Name string | ||
LogicalExpression PredicateLogicalExpression | ||
} | ||
|
||
type Builder interface { | ||
Build(name, variable, expression string) (*Predicate, error) | ||
} | ||
|
||
type PredicateBuilder struct { | ||
} | ||
|
||
var _ Builder = (*PredicateBuilder)(nil) | ||
|
||
func (p *PredicateBuilder) Build(name, variable, expression string) (*Predicate, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.