jroimartin commented on code in PR #1700:
URL: https://github.com/apache/tinkerpop/pull/1700#discussion_r902994138


##########
gremlin-go/driver/connection_test.go:
##########
@@ -1121,4 +1121,26 @@ func TestConnection(t *testing.T) {
                // This routine.
                assert.Equal(t, startCount, runtime.NumGoroutine())
        })
+
+       t.Run("Test per-request arguments", func(t *testing.T) {
+               skipTestsIfNotEnabled(t, integrationTestSuiteName, 
testNoAuthEnable)
+
+               g := getTestGraph(t, testNoAuthUrl, testNoAuthAuthInfo, 
testNoAuthTlsConfig)
+               defer g.remoteConnection.Close()
+
+               _, err := g.With("evaluationTimeout", 
10).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", "gremlin-groovy"}).Next()
+               assert.NotNil(t, err)
+
+               _, err = g.With("evaluationTimeout", 
10000).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Next()
+               assert.Nil(t, err)
+
+               _, err = g.With("evaluationTimeout", 
10000).With("evaluationTimeout", 
10).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", "gremlin-groovy"}).Next()
+               assert.NotNil(t, err)
+
+               _, err = 
g.WithStrategies(OptionsStrategy(map[string]interface{}{"evaluationTimeout": 
10})).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Next()
+               assert.NotNil(t, err)
+
+               _, err = 
g.WithStrategies(OptionsStrategy(map[string]interface{}{"evaluationTimeout": 
10000})).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Next()
+               assert.Nil(t, err)
+       })

Review Comment:
   @lyndonbauto sorry, but isn't this essentially the same that I did in 
866364ce328c7a91bac62366815224f30c0f9601?
   
   I did it table-driven because this way it is easier to add new test cases 
(you just have to add a new entry to the table) and everything related to a 
test case is grouped together (each table entry contains the description of the 
test case, the traversal and the expected error).
   
   ```go
   reqArgsTests := []struct {
        msg       string
        traversal *GraphTraversal
        nilErr    bool
   }{
        {
                "Traversal must time out (With)",
                g.With("evaluationTimeout", 
10).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", "gremlin-groovy"}),
                false,
        },
        {
                "Traversal must finish (With)",
                g.With("evaluationTimeout", 
10000).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", "gremlin-groovy"}),
                true,
        },
        {
                "evaluationTimeout is overridden and traversal must time out 
(With)",
                g.With("evaluationTimeout", 10000).With("evaluationTimeout", 
10).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", "gremlin-groovy"}),
                false,
        },
        {
                "Traversal must time out (OptionsStrategy)",
                
g.WithStrategies(OptionsStrategy(map[string]interface{}{"evaluationTimeout": 
10})).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", "gremlin-groovy"}),
                false,
        },
        {
                "Traversal must finish (OptionsStrategy)",
                
g.WithStrategies(OptionsStrategy(map[string]interface{}{"evaluationTimeout": 
10000})).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", "gremlin-groovy"}),
                true,
        },
   }
   ```
   
   Of course, if you prefer, I can change it to what you proposed:
   
   ```go
   err1 := g.With("evaluationTimeout", 
10).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Iterate()
   err2 := g.With("evaluationTimeout", 
10000).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Iterate()
   err3 := g.With("evaluationTimeout", 10000).With("evaluationTimeout", 
10).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Iterate()
   err4 := 
g.WithStrategies(OptionsStrategy(map[string]interface{}{"evaluationTimeout": 
10})).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Itearte()
   err5 := 
g.WithStrategies(OptionsStrategy(map[string]interface{}{"evaluationTimeout": 
10000})).Inject(1).SideEffect(&Lambda{"Thread.sleep(5000)", 
"gremlin-groovy"}).Iterate()
   
   assert.NotNil(t, <-err1)
   assert.Nil(t, <-err2)
   assert.NotNil(t, <-err3)
   assert.NotNil(t, <-err4)
   assert.Nil(t, <-err5)
   ```
   
   Which is shorter, but then the asserts are not next to the test cases, which 
IMHO make it harder to read and maintain. For instance when you want to add a 
new test case in the middle of the existing ones.
   
   What do you think? Of course, I'm more than happy to change it if that helps 
to follow the coding guidelines of the project of if I missed something.
   
   Regarding the gremlin-server error. Am I doing anything wrong? Should I send 
a bug report?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to