mattjackson220 commented on a change in pull request #5043:
URL: https://github.com/apache/trafficcontrol/pull/5043#discussion_r496252226



##########
File path: traffic_ops/traffic_ops_golang/asn/asns_test.go
##########
@@ -134,3 +134,39 @@ func TestValidate(t *testing.T) {
                t.Errorf(`expected %v,  got %v`, expected, errs)
        }
 }
+
+func TestValidateASNExists(t *testing.T) {
+       expected := `an asn with the specified number already 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{"id"}
+       rows := sqlmock.NewRows(cols)
+       rows = rows.AddRow(
+               1,
+       )
+       mock.ExpectBegin()
+       mock.ExpectQuery("SELECT").WillReturnRows(rows)
+       mock.ExpectCommit()
+
+       reqInfo := api.APIInfo{Tx: db.MustBegin()}
+       asnNum := 2
+       cachegroupID := 10
+       asn := TOASNV11{
+               api.APIInfoImpl{&reqInfo},
+               tc.ASNNullable{ASN: &asnNum, CachegroupID: &cachegroupID},
+       }
+       err = asn.ASNExists()
+       if err == nil {
+               t.Fatalf("expected no error but got %v", err.Error())

Review comment:
       this error message is flipped. should be "expected an error but got 
error = nil"




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