Skip to content

Commit

Permalink
Bump to 8.1 dev and govet clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
xllora committed Jul 19, 2017
1 parent 5e87b23 commit 0bcd381
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 41 deletions.
38 changes: 19 additions & 19 deletions bql/grammar/grammar_test.go
Expand Up @@ -338,16 +338,16 @@ func TestAcceptGraphOpsByParseAndSemantic(t *testing.T) {
t.Errorf("Parser.consume: Failed to accept entry %q with error %v", entry, err)
}
if got, want := st.GraphNames(), entry.graphs; !reflect.DeepEqual(got, want) {
t.Errorf("Parser.consume: Failed to collect the right graphs for case %v; got %d, want %d", entry, got, want)
t.Errorf("Parser.consume: Failed to collect the right graphs for case %v; got %v, want %v", entry, got, want)
}
if got, want := st.InputGraphNames(), entry.inputGraphs; !reflect.DeepEqual(got, want) {
t.Errorf("Parser.consume: Failed to collect the right input graphs for case %v; got %d, want %d", entry, got, want)
t.Errorf("Parser.consume: Failed to collect the right input graphs for case %v; got %v, want %v", entry, got, want)
}
if got, want := st.OutputGraphNames(), entry.outputGraphs; !reflect.DeepEqual(got, want) {
t.Errorf("Parser.consume: Failed to collect the right output graphs for case %v; got %d, want %d", entry, got, want)
t.Errorf("Parser.consume: Failed to collect the right output graphs for case %v; got %v, want %v", entry, got, want)
}
if got, want := len(st.Data()), entry.triples; got != want {
t.Errorf("Parser.consume: Failed to collect right number of triples for case %v; got %d, want %d", entry, got, want)
t.Errorf("Parser.consume: Failed to collect right number of triples for case %v; got %v, want %v", entry, got, want)
}
}
}
Expand Down Expand Up @@ -505,9 +505,9 @@ func TestSemanticStatementConstructClausesLengthCorrectness(t *testing.T) {

func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) {
table := []struct {
query string
want_one int
want_two int
query string
wantOne int
wantTwo int
}{
{
query: `construct {?s "predicate_1"@[] ?o1;
Expand All @@ -518,8 +518,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) {
where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2.
?s "old_predicate_3"@[,] ?o3};`,
want_one: 2,
want_two: 1,
wantOne: 2,
wantTwo: 1,
},
{
query: `construct {?s "predicate_1"@[] ?o1;
Expand All @@ -533,8 +533,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) {
where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2.
?s1 "old_predicate_3"@[,] ?o3};`,
want_one: 3,
want_two: 3,
wantOne: 3,
wantTwo: 3,
},
{
query: `construct {?s "predicate_1"@[2015-07-19T13:12:04.669618843-07:00] ?o1;
Expand All @@ -545,8 +545,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) {
where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2.
?s "old_predicate_3"@[,] ?o3};`,
want_one: 2,
want_two: 1,
wantOne: 2,
wantTwo: 1,
},
{
query: `construct {?s "predicate_1"@[2015-07-19T13:12:04.669618843-07:00] ?o1;
Expand All @@ -560,8 +560,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) {
where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2.
?s1 "old_predicate_3"@[,] ?o3};`,
want_one: 3,
want_two: 3,
wantOne: 3,
wantTwo: 3,
},
{
query: `construct {?s "predicate_1"@[] ?o1;
Expand All @@ -575,8 +575,8 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) {
where {?s "old_predicate_1"@[,] ?o1.
?s "old_predicate_2"@[,] ?o2.
?s1 "old_predicate_3"@[,] AT ?t ?o3};`,
want_one: 3,
want_two: 3,
wantOne: 3,
wantTwo: 3,
},
}
p, err := NewParser(SemanticBQL())
Expand All @@ -588,10 +588,10 @@ func TestSemanticStatementPredicateObjectPairsLengthCorrectness(t *testing.T) {
if err := p.Parse(NewLLk(entry.query, 1), st); err != nil {
t.Errorf("Parser.consume: Failed to accept valid semantic entry %q", entry.query)
}
if got, want := len(st.ConstructClauses()[0].PredicateObjectPairs()), entry.want_one; got != want {
if got, want := len(st.ConstructClauses()[0].PredicateObjectPairs()), entry.wantOne; got != want {
t.Errorf("Invalid number of predicate-object pairs for query %q; got %d, want %d; %v", entry.query, got, want, st.ConstructClauses()[0].PredicateObjectPairs())
}
if got, want := len(st.ConstructClauses()[1].PredicateObjectPairs()), entry.want_two; got != want {
if got, want := len(st.ConstructClauses()[1].PredicateObjectPairs()), entry.wantTwo; got != want {
t.Errorf("Invalid number of predicate-object pairs for query %q; got %d, want %d; %v", entry.query, got, want, st.ConstructClauses()[0].PredicateObjectPairs())
}
}
Expand Down
3 changes: 1 addition & 2 deletions bql/planner/planner.go
Expand Up @@ -953,8 +953,7 @@ func (p *constructPlan) Execute(ctx context.Context) (*table.Table, error) {
// We need to reify a blank node.
rts, bn, err := t.Reify()
if err != nil {
fmt.Errorf("triple.Reify failed to reify %v with error %v", t, err)
return nil, err
return nil, fmt.Errorf("triple.Reify failed to reify %v with error %v", t, err)
}
for _, trpl := range rts[1:] {
tripChan <- trpl
Expand Down
18 changes: 9 additions & 9 deletions bql/planner/planner_test.go
Expand Up @@ -228,7 +228,7 @@ func TestPlannerDropGraph(t *testing.T) {
}
}

func populateStoreWithTriples(s storage.Store, ctx context.Context, gn string, triples string, tb testing.TB) {
func populateStoreWithTriples(ctx context.Context, s storage.Store, gn string, triples string, tb testing.TB) {
g, err := s.NewGraph(ctx, gn)
if err != nil {
tb.Fatalf("memory.NewGraph failed to create \"%v\" with error %v", gn, err)
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestPlannerQuery(t *testing.T) {
}

s, ctx := memory.NewStore(), context.Background()
populateStoreWithTriples(s, ctx, "?test", testTriples, t)
populateStoreWithTriples(ctx, s, "?test", testTriples, t)
p, err := grammar.NewParser(grammar.SemanticBQL())
if err != nil {
t.Fatalf("grammar.NewParser: should have produced a valid BQL parser with error %v", err)
Expand Down Expand Up @@ -550,8 +550,8 @@ func TestPlannerConstructAddsCorrectNumberofTriples(t *testing.T) {
for _, entry := range testTable {

s, ctx := memory.NewStore(), context.Background()
populateStoreWithTriples(s, ctx, "?src", constructTestSrcTriples, t)
populateStoreWithTriples(s, ctx, "?dest", constructTestDestTriples, t)
populateStoreWithTriples(ctx, s, "?src", constructTestSrcTriples, t)
populateStoreWithTriples(ctx, s, "?dest", constructTestDestTriples, t)

st := &semantic.Statement{}
if err := p.Parse(grammar.NewLLk(entry.s, 1), st); err != nil {
Expand Down Expand Up @@ -602,8 +602,8 @@ func TestPlannerConstructAddsCorrectTriples(t *testing.T) {
t.Errorf("grammar.NewParser: should have produced a valid BQL parser, %v", err)
}
s, ctx := memory.NewStore(), context.Background()
populateStoreWithTriples(s, ctx, "?src", constructTestSrcTriples, t)
populateStoreWithTriples(s, ctx, "?dest", "", t)
populateStoreWithTriples(ctx, s, "?src", constructTestSrcTriples, t)
populateStoreWithTriples(ctx, s, "?dest", "", t)

st := &semantic.Statement{}
if err := p.Parse(grammar.NewLLk(bql, 1), st); err != nil {
Expand Down Expand Up @@ -656,7 +656,7 @@ func TestPlannerConstructAddsCorrectTriples(t *testing.T) {
for elem := range ts {
sts = append(sts, elem)
if elem.Subject().Type().String() == "/_" {
for k, _ := range dtm {
for k := range dtm {
trp, err := triple.Parse(k, literal.DefaultBuilder())
if err != nil {
t.Errorf("Unable to parse triple: %v with error %v", k, err)
Expand All @@ -682,7 +682,7 @@ func TestPlannerConstructAddsCorrectTriples(t *testing.T) {
// checking if the triple exists in the map of expected triples.
for _, t := range sts {
if t.Subject().Type().String() == "/_" {
for bn, _ := range bnm[t.Subject().String()] {
for bn := range bnm[t.Subject().String()] {
rep := fmt.Sprintf("%s\t%s\t%s", bn, t.Predicate().String(), t.Object().String())
if _, ok := dtm[rep]; !ok {
bnm[t.Subject().String()][bn] = false
Expand Down Expand Up @@ -891,7 +891,7 @@ func benchmarkQuery(query string, b *testing.B) {
ctx := context.Background()

s, ctx := memory.NewStore(), context.Background()
populateStoreWithTriples(s, ctx, "?test", testTriples, b)
populateStoreWithTriples(ctx, s, "?test", testTriples, b)
p, err := grammar.NewParser(grammar.SemanticBQL())
if err != nil {
b.Fatalf("grammar.NewParser: should have produced a valid BQL parser with error %v", err)
Expand Down
4 changes: 2 additions & 2 deletions bql/semantic/semantic.go
Expand Up @@ -138,7 +138,7 @@ type ConstructClause struct {
S *node.Node
SBinding string

predicateObjectPairs []*ConstructPredicateObjectPair
predicateObjectPairs []*ConstructPredicateObjectPair
workingPredicateObjectPair *ConstructPredicateObjectPair
}

Expand Down Expand Up @@ -387,7 +387,7 @@ func (c *ConstructClause) String() string {
for _, pop := range c.PredicateObjectPairs() {
b.WriteString(fmt.Sprintf("%v;", pop))
}
b.Truncate(b.Len()-1)
b.Truncate(b.Len() - 1)
b.WriteString(" }")
return b.String()
}
Expand Down
4 changes: 2 additions & 2 deletions bql/version/version.go
Expand Up @@ -20,9 +20,9 @@ var (
// Minor is the current minor version of master branch.
Minor = 8
// Patch is the current patched version of the master branch.
Patch = 0
Patch = 1
// Release is the current release level of the master branch. Valid values
// are dev (development unreleased), rcX (release candidate with current
// iteration), stable (indicates a final released version).
Release = "stable"
Release = "dev"
)
2 changes: 1 addition & 1 deletion docs/command_line_tool.md
Expand Up @@ -378,7 +378,7 @@ $ badwolf export ?graph1,?graph2,?grpah3 ./triples.txt
## Command: Server

Ther ```server``` command starts a simple HTTP endpoint for BQL commands on
the provided port.
the provided port.

```
$ bw server 1234
Expand Down
6 changes: 3 additions & 3 deletions storage/storage.go
Expand Up @@ -126,7 +126,7 @@ type Graph interface {
Objects(ctx context.Context, s *node.Node, p *predicate.Predicate, lo *LookupOptions, objs chan<- *triple.Object) error

// Subject pushes to the provided channel the subjects for the give predicate
// and object. The function does not return immediately. The caller is
// and object. The function does not return immediately. The caller is
// expected to detach them into a go routine.
//
// Given a predicate and an object, this method retrieves the subjects of
Expand Down Expand Up @@ -180,7 +180,7 @@ type Graph interface {
PredicatesForSubjectAndObject(ctx context.Context, s *node.Node, o *triple.Object, lo *LookupOptions, prds chan<- *predicate.Predicate) error

// TriplesForSubject pushes to the provided channel all triples available for
// the given subject. The function does not return immediately. The caller
// the given subject. The function does not return immediately. The caller
// is expected to detach them into a go routine.
//
// If the lookup options provide a max number of elements the function will
Expand All @@ -191,7 +191,7 @@ type Graph interface {
TriplesForSubject(ctx context.Context, s *node.Node, lo *LookupOptions, trpls chan<- *triple.Triple) error

// TriplesForPredicate pushes to the provided channel all triples available
// for the given predicate.The function does not return immediatel. The
// for the given predicate.The function does not return immediatel. The
// caller is expected to detach them into a go routine.
//
// If the lookup options provide a max number of elements the function will
Expand Down
2 changes: 1 addition & 1 deletion tools/vcli/bw/repl/repl.go
Expand Up @@ -106,7 +106,7 @@ func REPL(driver storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize
fmt.Printf("Using driver %q. Type quit; to exit\n", driver.Name(ctx))
fmt.Printf("Session started at %v\n\n", sessionStart)
defer func() {
fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Now().Sub(sessionStart) )
fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Now().Sub(sessionStart))
}()

for l := range rl(done) {
Expand Down
2 changes: 1 addition & 1 deletion tools/vcli/bw/server/server.go
Expand Up @@ -98,7 +98,7 @@ func (s *serverConfig) bqlHandler(w http.ResponseWriter, r *http.Request) {
return
}
if r.Method != http.MethodPost {
reportError(w, r, fmt.Errorf("invalid %s request on %q endpoint. Only POST request are accepted.", r.Method, r.URL.Path))
reportError(w, r, fmt.Errorf("invalid %s request on %q endpoint. Only POST request are accepted", r.Method, r.URL.Path))
log.Printf("[%s] Invalid request: %#v\n", time.Now(), r)
return
}
Expand Down
2 changes: 1 addition & 1 deletion triple/node/node.go
Expand Up @@ -105,7 +105,7 @@ func Parse(s string) (*Node, error) {
if err != nil {
return nil, fmt.Errorf("node.Parse: invalid ID in %q, %v", raw, err)
}
t, _ := NewType("/_")
t, _ := NewType("/_")
return NewNode(t, id), nil
default:
return nil, fmt.Errorf("node.Parse: node representation should start with '/' or '_' in %v", raw)
Expand Down

0 comments on commit 0bcd381

Please sign in to comment.