rimashah25 commented on a change in pull request #5017:
URL: https://github.com/apache/trafficcontrol/pull/5017#discussion_r490411420



##########
File path: 
traffic_ops/traffic_ops_golang/deliveryservicesregexes/deliveryservicesregexes_test.go
##########
@@ -25,42 +26,64 @@ import (
  * under the License.
  */
 
-func TestValidateDSRegexOrder(t *testing.T) {
-       expected := `cannot add regex, another regex with the same order exists`
+func TestValidateDSRegexOrderExisting(t *testing.T) {
+       expected := `'setNumber' cannot add regex, another regex with the same 
order exists`
        mockDB, mock, err := sqlmock.New()
        if err != nil {
                t.Fatalf("an error '%s' was not expected when opening a stub 
database connection", err)
        }
        defer mockDB.Close()
-
        db := sqlx.NewDb(mockDB, "sqlmock")
        defer db.Close()
-       cols := []string{"deliveryservice"}
+       cols := []string{"name", "use_in_table"}
        rows := sqlmock.NewRows(cols)
        rows = rows.AddRow(
+               "HTTP",
+               "regex",
+       )
+       cols2 := []string{"deliveryservice"}
+       rows2 := sqlmock.NewRows(cols2)
+       rows2 = rows2.AddRow(
                1,
        )
+
+       regex := tc.DeliveryServiceRegexPost{Type: 33, SetNumber: 3, Pattern: 
".*"}
        mock.ExpectBegin()
-       mock.ExpectQuery("select").WithArgs(1, 3).WillReturnRows(rows)
+       mock.ExpectQuery("select").WithArgs(1, 
regex.SetNumber).WillReturnRows(rows2)
+       mock.ExpectQuery("SELECT").WithArgs(regex.Type).WillReturnRows(rows)
+       mock.ExpectCommit()
        tx := db.MustBegin().Tx
-       err = validateDSRegexOrder(tx, 1, 3)
+       err = validateDSRegex(tx, regex, 1)
        if err == nil {
-               t.Fatal("Expected error but got nil")
+               t.Fatalf("Expected error %v but got none", expected)

Review comment:
       Ok, changed it.




----------------------------------------------------------------
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.

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


Reply via email to