Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ JOIN deliveryservice_regex as dsr ON dsr.regex = r.id
JOIN deliveryservice as ds on ds.id = dsr.deliveryservice
JOIN type as t ON r.type = t.id
WHERE ds.xml_id = ANY($1)
ORDER BY dsr.set_number
`
rows, err := tx.Query(q, pq.Array(dses))
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,31 @@ import (

"github.com/apache/trafficcontrol/lib/go-tc"
"github.com/apache/trafficcontrol/lib/go-util"

"github.com/jmoiron/sqlx"
"gopkg.in/DATA-DOG/go-sqlmock.v1"
)

func TestGetDeliveryServicesMatchLists(t *testing.T) {
// test to make sure that the DS matchlists query orders by set_number
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()

mock.ExpectBegin()
mock.ExpectQuery("SELECT .+ ORDER BY dsr.set_number")

GetDeliveryServicesMatchLists([]string{"foo"}, db.MustBegin().Tx)
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("expectations were not met: %s", err)
}
}

func TestMakeExampleURLs(t *testing.T) {
expected := []string{
`http://routing-name.ds-name.domain-name.invalid`,
Expand Down