You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/08/14 20:39:08 UTC

[1/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 9c8f5b52a -> 3598cffd5


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_test.go
deleted file mode 100644
index 2e3c097..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_test.go
+++ /dev/null
@@ -1,154 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql/driver"
-	"fmt"
-	"regexp"
-	"testing"
-	"time"
-)
-
-func TestQueryExpectationArgComparison(t *testing.T) {
-	e := &queryBasedExpectation{}
-	against := []namedValue{{Value: int64(5), Ordinal: 1}}
-	if err := e.argsMatches(against); err != nil {
-		t.Errorf("arguments should match, since the no expectation was set, but got err: %s", err)
-	}
-
-	e.args = []driver.Value{5, "str"}
-
-	against = []namedValue{{Value: int64(5), Ordinal: 1}}
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments should not match, since the size is not the same")
-	}
-
-	against = []namedValue{
-		{Value: int64(3), Ordinal: 1},
-		{Value: "str", Ordinal: 2},
-	}
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments should not match, since the first argument (int value) is different")
-	}
-
-	against = []namedValue{
-		{Value: int64(5), Ordinal: 1},
-		{Value: "st", Ordinal: 2},
-	}
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments should not match, since the second argument (string value) is different")
-	}
-
-	against = []namedValue{
-		{Value: int64(5), Ordinal: 1},
-		{Value: "str", Ordinal: 2},
-	}
-	if err := e.argsMatches(against); err != nil {
-		t.Errorf("arguments should match, but it did not: %s", err)
-	}
-
-	const longForm = "Jan 2, 2006 at 3:04pm (MST)"
-	tm, _ := time.Parse(longForm, "Feb 3, 2013 at 7:54pm (PST)")
-	e.args = []driver.Value{5, tm}
-
-	against = []namedValue{
-		{Value: int64(5), Ordinal: 1},
-		{Value: tm, Ordinal: 2},
-	}
-	if err := e.argsMatches(against); err != nil {
-		t.Error("arguments should match, but it did not")
-	}
-
-	e.args = []driver.Value{5, AnyArg()}
-	if err := e.argsMatches(against); err != nil {
-		t.Errorf("arguments should match, but it did not: %s", err)
-	}
-}
-
-func TestQueryExpectationArgComparisonBool(t *testing.T) {
-	var e *queryBasedExpectation
-
-	e = &queryBasedExpectation{args: []driver.Value{true}}
-	against := []namedValue{
-		{Value: true, Ordinal: 1},
-	}
-	if err := e.argsMatches(against); err != nil {
-		t.Error("arguments should match, since arguments are the same")
-	}
-
-	e = &queryBasedExpectation{args: []driver.Value{false}}
-	against = []namedValue{
-		{Value: false, Ordinal: 1},
-	}
-	if err := e.argsMatches(against); err != nil {
-		t.Error("arguments should match, since argument are the same")
-	}
-
-	e = &queryBasedExpectation{args: []driver.Value{true}}
-	against = []namedValue{
-		{Value: false, Ordinal: 1},
-	}
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments should not match, since argument is different")
-	}
-
-	e = &queryBasedExpectation{args: []driver.Value{false}}
-	against = []namedValue{
-		{Value: true, Ordinal: 1},
-	}
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments should not match, since argument is different")
-	}
-}
-
-func TestQueryExpectationSqlMatch(t *testing.T) {
-	e := &ExpectedExec{}
-
-	e.sqlRegex = regexp.MustCompile("SELECT x FROM")
-	if !e.queryMatches("SELECT x FROM someting") {
-		t.Errorf("Sql must have matched the query")
-	}
-
-	e.sqlRegex = regexp.MustCompile("SELECT COUNT\\(x\\) FROM")
-	if !e.queryMatches("SELECT COUNT(x) FROM someting") {
-		t.Errorf("Sql must have matched the query")
-	}
-}
-
-func ExampleExpectedExec() {
-	db, mock, _ := New()
-	result := NewErrorResult(fmt.Errorf("some error"))
-	mock.ExpectExec("^INSERT (.+)").WillReturnResult(result)
-	res, _ := db.Exec("INSERT something")
-	_, err := res.LastInsertId()
-	fmt.Println(err)
-	// Output: some error
-}
-
-func TestBuildQuery(t *testing.T) {
-	db, mock, _ := New()
-	query := `
-		SELECT
-			name,
-			email,
-			address,
-			anotherfield
-		FROM user
-		where
-			name    = 'John'
-			and
-			address = 'Jakarta'
-
-	`
-
-	mock.ExpectQuery(query)
-	mock.ExpectExec(query)
-	mock.ExpectPrepare(query)
-
-	db.QueryRow(query)
-	db.Exec(query)
-	db.Prepare(query)
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Error(err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result.go
deleted file mode 100644
index a63e72b..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql/driver"
-)
-
-// Result satisfies sql driver Result, which
-// holds last insert id and rows affected
-// by Exec queries
-type result struct {
-	insertID     int64
-	rowsAffected int64
-	err          error
-}
-
-// NewResult creates a new sql driver Result
-// for Exec based query mocks.
-func NewResult(lastInsertID int64, rowsAffected int64) driver.Result {
-	return &result{
-		insertID:     lastInsertID,
-		rowsAffected: rowsAffected,
-	}
-}
-
-// NewErrorResult creates a new sql driver Result
-// which returns an error given for both interface methods
-func NewErrorResult(err error) driver.Result {
-	return &result{
-		err: err,
-	}
-}
-
-func (r *result) LastInsertId() (int64, error) {
-	return r.insertID, r.err
-}
-
-func (r *result) RowsAffected() (int64, error) {
-	return r.rowsAffected, r.err
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result_test.go
deleted file mode 100644
index 08d47c9..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/result_test.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package sqlmock
-
-import (
-	"fmt"
-	"testing"
-)
-
-// used for examples
-var mock = &sqlmock{}
-
-func ExampleNewErrorResult() {
-	db, mock, _ := New()
-	result := NewErrorResult(fmt.Errorf("some error"))
-	mock.ExpectExec("^INSERT (.+)").WillReturnResult(result)
-	res, _ := db.Exec("INSERT something")
-	_, err := res.LastInsertId()
-	fmt.Println(err)
-	// Output: some error
-}
-
-func ExampleNewResult() {
-	var lastInsertID, affected int64
-	result := NewResult(lastInsertID, affected)
-	mock.ExpectExec("^INSERT (.+)").WillReturnResult(result)
-	fmt.Println(mock.ExpectationsWereMet())
-	// Output: there is a remaining expectation which was not matched: ExpectedExec => expecting Exec which:
-	//   - matches sql: '^INSERT (.+)'
-	//   - is without arguments
-	//   - should return Result having:
-	//       LastInsertId: 0
-	//       RowsAffected: 0
-}
-
-func TestShouldReturnValidSqlDriverResult(t *testing.T) {
-	result := NewResult(1, 2)
-	id, err := result.LastInsertId()
-	if 1 != id {
-		t.Errorf("Expected last insert id to be 1, but got: %d", id)
-	}
-	if err != nil {
-		t.Errorf("expected no error, but got: %s", err)
-	}
-	affected, err := result.RowsAffected()
-	if 2 != affected {
-		t.Errorf("Expected affected rows to be 2, but got: %d", affected)
-	}
-	if err != nil {
-		t.Errorf("expected no error, but got: %s", err)
-	}
-}
-
-func TestShouldReturnErroeSqlDriverResult(t *testing.T) {
-	result := NewErrorResult(fmt.Errorf("some error"))
-	_, err := result.LastInsertId()
-	if err == nil {
-		t.Error("expected error, but got none")
-	}
-	_, err = result.RowsAffected()
-	if err == nil {
-		t.Error("expected error, but got none")
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows.go
deleted file mode 100644
index 39f9f83..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows.go
+++ /dev/null
@@ -1,144 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql/driver"
-	"encoding/csv"
-	"fmt"
-	"io"
-	"strings"
-)
-
-// CSVColumnParser is a function which converts trimmed csv
-// column string to a []byte representation. currently
-// transforms NULL to nil
-var CSVColumnParser = func(s string) []byte {
-	switch {
-	case strings.ToLower(s) == "null":
-		return nil
-	}
-	return []byte(s)
-}
-
-type rowSets struct {
-	sets []*Rows
-	pos  int
-}
-
-func (rs *rowSets) Columns() []string {
-	return rs.sets[rs.pos].cols
-}
-
-func (rs *rowSets) Close() error {
-	return rs.sets[rs.pos].closeErr
-}
-
-// advances to next row
-func (rs *rowSets) Next(dest []driver.Value) error {
-	r := rs.sets[rs.pos]
-	r.pos++
-	if r.pos > len(r.rows) {
-		return io.EOF // per interface spec
-	}
-
-	for i, col := range r.rows[r.pos-1] {
-		dest[i] = col
-	}
-
-	return r.nextErr[r.pos-1]
-}
-
-// transforms to debuggable printable string
-func (rs *rowSets) String() string {
-	msg := "should return rows:\n"
-	if len(rs.sets) == 1 {
-		for n, row := range rs.sets[0].rows {
-			msg += fmt.Sprintf("    row %d - %+v\n", n, row)
-		}
-		return strings.TrimSpace(msg)
-	}
-	for i, set := range rs.sets {
-		msg += fmt.Sprintf("    result set: %d\n", i)
-		for n, row := range set.rows {
-			msg += fmt.Sprintf("      row %d - %+v\n", n, row)
-		}
-	}
-	return strings.TrimSpace(msg)
-}
-
-// Rows is a mocked collection of rows to
-// return for Query result
-type Rows struct {
-	cols     []string
-	rows     [][]driver.Value
-	pos      int
-	nextErr  map[int]error
-	closeErr error
-}
-
-// NewRows allows Rows to be created from a
-// sql driver.Value slice or from the CSV string and
-// to be used as sql driver.Rows
-func NewRows(columns []string) *Rows {
-	return &Rows{cols: columns, nextErr: make(map[int]error)}
-}
-
-// CloseError allows to set an error
-// which will be returned by rows.Close
-// function.
-//
-// The close error will be triggered only in cases
-// when rows.Next() EOF was not yet reached, that is
-// a default sql library behavior
-func (r *Rows) CloseError(err error) *Rows {
-	r.closeErr = err
-	return r
-}
-
-// RowError allows to set an error
-// which will be returned when a given
-// row number is read
-func (r *Rows) RowError(row int, err error) *Rows {
-	r.nextErr[row] = err
-	return r
-}
-
-// AddRow composed from database driver.Value slice
-// return the same instance to perform subsequent actions.
-// Note that the number of values must match the number
-// of columns
-func (r *Rows) AddRow(values ...driver.Value) *Rows {
-	if len(values) != len(r.cols) {
-		panic("Expected number of values to match number of columns")
-	}
-
-	row := make([]driver.Value, len(r.cols))
-	for i, v := range values {
-		row[i] = v
-	}
-
-	r.rows = append(r.rows, row)
-	return r
-}
-
-// FromCSVString build rows from csv string.
-// return the same instance to perform subsequent actions.
-// Note that the number of values must match the number
-// of columns
-func (r *Rows) FromCSVString(s string) *Rows {
-	res := strings.NewReader(strings.TrimSpace(s))
-	csvReader := csv.NewReader(res)
-
-	for {
-		res, err := csvReader.Read()
-		if err != nil || res == nil {
-			break
-		}
-
-		row := make([]driver.Value, len(r.cols))
-		for i, v := range res {
-			row[i] = CSVColumnParser(strings.TrimSpace(v))
-		}
-		r.rows = append(r.rows, row)
-	}
-	return r
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18.go
deleted file mode 100644
index 4ecf84e..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// +build go1.8
-
-package sqlmock
-
-import "io"
-
-// Implement the "RowsNextResultSet" interface
-func (rs *rowSets) HasNextResultSet() bool {
-	return rs.pos+1 < len(rs.sets)
-}
-
-// Implement the "RowsNextResultSet" interface
-func (rs *rowSets) NextResultSet() error {
-	if !rs.HasNextResultSet() {
-		return io.EOF
-	}
-
-	rs.pos++
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18_test.go
deleted file mode 100644
index 297e7c0..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_go18_test.go
+++ /dev/null
@@ -1,92 +0,0 @@
-// +build go1.8
-
-package sqlmock
-
-import (
-	"fmt"
-	"testing"
-)
-
-func TestQueryMultiRows(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs1 := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
-	rs2 := NewRows([]string{"name"}).AddRow("gopher").AddRow("john").AddRow("jane").RowError(2, fmt.Errorf("error"))
-
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = \\?;SELECT name FROM users").
-		WithArgs(5).
-		WillReturnRows(rs1, rs2)
-
-	rows, err := db.Query("SELECT id, title FROM articles WHERE id = ?;SELECT name FROM users", 5)
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-	defer rows.Close()
-
-	if !rows.Next() {
-		t.Error("expected a row to be available in first result set")
-	}
-
-	var id int
-	var name string
-
-	err = rows.Scan(&id, &name)
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	if id != 5 || name != "hello world" {
-		t.Errorf("unexpected row values id: %v name: %v", id, name)
-	}
-
-	if rows.Next() {
-		t.Error("was not expecting next row in first result set")
-	}
-
-	if !rows.NextResultSet() {
-		t.Error("had to have next result set")
-	}
-
-	if !rows.Next() {
-		t.Error("expected a row to be available in second result set")
-	}
-
-	err = rows.Scan(&name)
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	if name != "gopher" {
-		t.Errorf("unexpected row name: %v", name)
-	}
-
-	if !rows.Next() {
-		t.Error("expected a row to be available in second result set")
-	}
-
-	err = rows.Scan(&name)
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	if name != "john" {
-		t.Errorf("unexpected row name: %v", name)
-	}
-
-	if rows.Next() {
-		t.Error("expected next row to produce error")
-	}
-
-	if rows.Err() == nil {
-		t.Error("expected an error, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_test.go
deleted file mode 100644
index 56e834e..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/rows_test.go
+++ /dev/null
@@ -1,265 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql"
-	"fmt"
-	"testing"
-)
-
-func ExampleRows() {
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("failed to open sqlmock database:", err)
-	}
-	defer db.Close()
-
-	rows := NewRows([]string{"id", "title"}).
-		AddRow(1, "one").
-		AddRow(2, "two")
-
-	mock.ExpectQuery("SELECT").WillReturnRows(rows)
-
-	rs, _ := db.Query("SELECT")
-	defer rs.Close()
-
-	for rs.Next() {
-		var id int
-		var title string
-		rs.Scan(&id, &title)
-		fmt.Println("scanned id:", id, "and title:", title)
-	}
-
-	if rs.Err() != nil {
-		fmt.Println("got rows error:", rs.Err())
-	}
-	// Output: scanned id: 1 and title: one
-	// scanned id: 2 and title: two
-}
-
-func ExampleRows_rowError() {
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("failed to open sqlmock database:", err)
-	}
-	defer db.Close()
-
-	rows := NewRows([]string{"id", "title"}).
-		AddRow(0, "one").
-		AddRow(1, "two").
-		RowError(1, fmt.Errorf("row error"))
-	mock.ExpectQuery("SELECT").WillReturnRows(rows)
-
-	rs, _ := db.Query("SELECT")
-	defer rs.Close()
-
-	for rs.Next() {
-		var id int
-		var title string
-		rs.Scan(&id, &title)
-		fmt.Println("scanned id:", id, "and title:", title)
-	}
-
-	if rs.Err() != nil {
-		fmt.Println("got rows error:", rs.Err())
-	}
-	// Output: scanned id: 0 and title: one
-	// got rows error: row error
-}
-
-func ExampleRows_closeError() {
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("failed to open sqlmock database:", err)
-	}
-	defer db.Close()
-
-	rows := NewRows([]string{"id", "title"}).CloseError(fmt.Errorf("close error"))
-	mock.ExpectQuery("SELECT").WillReturnRows(rows)
-
-	rs, _ := db.Query("SELECT")
-
-	// Note: that close will return error only before rows EOF
-	// that is a default sql package behavior. If you run rs.Next()
-	// it will handle the error internally and return nil bellow
-	if err := rs.Close(); err != nil {
-		fmt.Println("got error:", err)
-	}
-
-	// Output: got error: close error
-}
-
-func TestAllowsToSetRowsErrors(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rows := NewRows([]string{"id", "title"}).
-		AddRow(0, "one").
-		AddRow(1, "two").
-		RowError(1, fmt.Errorf("error"))
-	mock.ExpectQuery("SELECT").WillReturnRows(rows)
-
-	rs, err := db.Query("SELECT")
-	if err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-	defer rs.Close()
-
-	if !rs.Next() {
-		t.Fatal("expected the first row to be available")
-	}
-	if rs.Err() != nil {
-		t.Fatalf("unexpected error: %s", rs.Err())
-	}
-
-	if rs.Next() {
-		t.Fatal("was not expecting the second row, since there should be an error")
-	}
-	if rs.Err() == nil {
-		t.Fatal("expected an error, but got none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestRowsCloseError(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rows := NewRows([]string{"id"}).CloseError(fmt.Errorf("close error"))
-	mock.ExpectQuery("SELECT").WillReturnRows(rows)
-
-	rs, err := db.Query("SELECT")
-	if err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-
-	if err := rs.Close(); err == nil {
-		t.Fatal("expected a close error")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestQuerySingleRow(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rows := NewRows([]string{"id"}).
-		AddRow(1).
-		AddRow(2)
-	mock.ExpectQuery("SELECT").WillReturnRows(rows)
-
-	var id int
-	if err := db.QueryRow("SELECT").Scan(&id); err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-
-	mock.ExpectQuery("SELECT").WillReturnRows(NewRows([]string{"id"}))
-	if err := db.QueryRow("SELECT").Scan(&id); err != sql.ErrNoRows {
-		t.Fatal("expected sql no rows error")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestRowsScanError(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	r := NewRows([]string{"col1", "col2"}).AddRow("one", "two").AddRow("one", nil)
-	mock.ExpectQuery("SELECT").WillReturnRows(r)
-
-	rs, err := db.Query("SELECT")
-	if err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-	defer rs.Close()
-
-	var one, two string
-	if !rs.Next() || rs.Err() != nil || rs.Scan(&one, &two) != nil {
-		t.Fatal("unexpected error on first row scan")
-	}
-
-	if !rs.Next() || rs.Err() != nil {
-		t.Fatal("unexpected error on second row read")
-	}
-
-	err = rs.Scan(&one, &two)
-	if err == nil {
-		t.Fatal("expected an error for scan, but got none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestCSVRowParser(t *testing.T) {
-	t.Parallel()
-	rs := NewRows([]string{"col1", "col2"}).FromCSVString("a,NULL")
-	db, mock, err := New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectQuery("SELECT").WillReturnRows(rs)
-
-	rw, err := db.Query("SELECT")
-	if err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-	defer rw.Close()
-	var col1 string
-	var col2 []byte
-
-	rw.Next()
-	if err = rw.Scan(&col1, &col2); err != nil {
-		t.Fatalf("unexpected error: %s", err)
-	}
-	if col1 != "a" {
-		t.Fatalf("expected col1 to be 'a', but got [%T]:%+v", col1, col1)
-	}
-	if col2 != nil {
-		t.Fatalf("expected col2 to be nil, but got [%T]:%+v", col2, col2)
-	}
-}
-
-func TestWrongNumberOfValues(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	defer db.Close()
-	defer func() {
-		recover()
-	}()
-	mock.ExpectQuery("SELECT ID FROM TABLE").WithArgs(101).WillReturnRows(NewRows([]string{"ID"}).AddRow(101, "Hello"))
-	db.Query("SELECT ID FROM TABLE", 101)
-	// shouldn't reach here
-	t.Error("expected panic from query")
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock.go
deleted file mode 100644
index b906a3f..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock.go
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
-Package sqlmock is a mock library implementing sql driver. Which has one and only
-purpose - to simulate any sql driver behavior in tests, without needing a real
-database connection. It helps to maintain correct **TDD** workflow.
-
-It does not require any modifications to your source code in order to test
-and mock database operations. Supports concurrency and multiple database mocking.
-
-The driver allows to mock any sql driver method behavior.
-*/
-package sqlmock
-
-import (
-	"database/sql"
-	"database/sql/driver"
-	"fmt"
-	"regexp"
-	"time"
-)
-
-// Sqlmock interface serves to create expectations
-// for any kind of database action in order to mock
-// and test real database behavior.
-type Sqlmock interface {
-
-	// ExpectClose queues an expectation for this database
-	// action to be triggered. the *ExpectedClose allows
-	// to mock database response
-	ExpectClose() *ExpectedClose
-
-	// ExpectationsWereMet checks whether all queued expectations
-	// were met in order. If any of them was not met - an error is returned.
-	ExpectationsWereMet() error
-
-	// ExpectPrepare expects Prepare() to be called with sql query
-	// which match sqlRegexStr given regexp.
-	// the *ExpectedPrepare allows to mock database response.
-	// Note that you may expect Query() or Exec() on the *ExpectedPrepare
-	// statement to prevent repeating sqlRegexStr
-	ExpectPrepare(sqlRegexStr string) *ExpectedPrepare
-
-	// ExpectQuery expects Query() or QueryRow() to be called with sql query
-	// which match sqlRegexStr given regexp.
-	// the *ExpectedQuery allows to mock database response.
-	ExpectQuery(sqlRegexStr string) *ExpectedQuery
-
-	// ExpectExec expects Exec() to be called with sql query
-	// which match sqlRegexStr given regexp.
-	// the *ExpectedExec allows to mock database response
-	ExpectExec(sqlRegexStr string) *ExpectedExec
-
-	// ExpectBegin expects *sql.DB.Begin to be called.
-	// the *ExpectedBegin allows to mock database response
-	ExpectBegin() *ExpectedBegin
-
-	// ExpectCommit expects *sql.Tx.Commit to be called.
-	// the *ExpectedCommit allows to mock database response
-	ExpectCommit() *ExpectedCommit
-
-	// ExpectRollback expects *sql.Tx.Rollback to be called.
-	// the *ExpectedRollback allows to mock database response
-	ExpectRollback() *ExpectedRollback
-
-	// MatchExpectationsInOrder gives an option whether to match all
-	// expectations in the order they were set or not.
-	//
-	// By default it is set to - true. But if you use goroutines
-	// to parallelize your query executation, that option may
-	// be handy.
-	//
-	// This option may be turned on anytime during tests. As soon
-	// as it is switched to false, expectations will be matched
-	// in any order. Or otherwise if switched to true, any unmatched
-	// expectations will be expected in order
-	MatchExpectationsInOrder(bool)
-}
-
-type sqlmock struct {
-	ordered bool
-	dsn     string
-	opened  int
-	drv     *mockDriver
-
-	expected []expectation
-}
-
-func (c *sqlmock) open() (*sql.DB, Sqlmock, error) {
-	db, err := sql.Open("sqlmock", c.dsn)
-	if err != nil {
-		return db, c, err
-	}
-	return db, c, db.Ping()
-}
-
-func (c *sqlmock) ExpectClose() *ExpectedClose {
-	e := &ExpectedClose{}
-	c.expected = append(c.expected, e)
-	return e
-}
-
-func (c *sqlmock) MatchExpectationsInOrder(b bool) {
-	c.ordered = b
-}
-
-// Close a mock database driver connection. It may or may not
-// be called depending on the sircumstances, but if it is called
-// there must be an *ExpectedClose expectation satisfied.
-// meets http://golang.org/pkg/database/sql/driver/#Conn interface
-func (c *sqlmock) Close() error {
-	c.drv.Lock()
-	defer c.drv.Unlock()
-
-	c.opened--
-	if c.opened == 0 {
-		delete(c.drv.conns, c.dsn)
-	}
-
-	var expected *ExpectedClose
-	var fulfilled int
-	var ok bool
-	for _, next := range c.expected {
-		next.Lock()
-		if next.fulfilled() {
-			next.Unlock()
-			fulfilled++
-			continue
-		}
-
-		if expected, ok = next.(*ExpectedClose); ok {
-			break
-		}
-
-		next.Unlock()
-		if c.ordered {
-			return fmt.Errorf("call to database Close, was not expected, next expectation is: %s", next)
-		}
-	}
-
-	if expected == nil {
-		msg := "call to database Close was not expected"
-		if fulfilled == len(c.expected) {
-			msg = "all expectations were already fulfilled, " + msg
-		}
-		return fmt.Errorf(msg)
-	}
-
-	expected.triggered = true
-	expected.Unlock()
-	return expected.err
-}
-
-func (c *sqlmock) ExpectationsWereMet() error {
-	for _, e := range c.expected {
-		if !e.fulfilled() {
-			return fmt.Errorf("there is a remaining expectation which was not matched: %s", e)
-		}
-	}
-	return nil
-}
-
-// Begin meets http://golang.org/pkg/database/sql/driver/#Conn interface
-func (c *sqlmock) Begin() (driver.Tx, error) {
-	ex, err := c.begin()
-	if err != nil {
-		return nil, err
-	}
-
-	time.Sleep(ex.delay)
-	return c, nil
-}
-
-func (c *sqlmock) begin() (*ExpectedBegin, error) {
-	var expected *ExpectedBegin
-	var ok bool
-	var fulfilled int
-	for _, next := range c.expected {
-		next.Lock()
-		if next.fulfilled() {
-			next.Unlock()
-			fulfilled++
-			continue
-		}
-
-		if expected, ok = next.(*ExpectedBegin); ok {
-			break
-		}
-
-		next.Unlock()
-		if c.ordered {
-			return nil, fmt.Errorf("call to database transaction Begin, was not expected, next expectation is: %s", next)
-		}
-	}
-	if expected == nil {
-		msg := "call to database transaction Begin was not expected"
-		if fulfilled == len(c.expected) {
-			msg = "all expectations were already fulfilled, " + msg
-		}
-		return nil, fmt.Errorf(msg)
-	}
-
-	expected.triggered = true
-	expected.Unlock()
-
-	return expected, expected.err
-}
-
-func (c *sqlmock) ExpectBegin() *ExpectedBegin {
-	e := &ExpectedBegin{}
-	c.expected = append(c.expected, e)
-	return e
-}
-
-// Exec meets http://golang.org/pkg/database/sql/driver/#Execer
-func (c *sqlmock) Exec(query string, args []driver.Value) (driver.Result, error) {
-	namedArgs := make([]namedValue, len(args))
-	for i, v := range args {
-		namedArgs[i] = namedValue{
-			Ordinal: i + 1,
-			Value:   v,
-		}
-	}
-
-	ex, err := c.exec(query, namedArgs)
-	if err != nil {
-		return nil, err
-	}
-
-	time.Sleep(ex.delay)
-	return ex.result, nil
-}
-
-func (c *sqlmock) exec(query string, args []namedValue) (*ExpectedExec, error) {
-	query = stripQuery(query)
-	var expected *ExpectedExec
-	var fulfilled int
-	var ok bool
-	for _, next := range c.expected {
-		next.Lock()
-		if next.fulfilled() {
-			next.Unlock()
-			fulfilled++
-			continue
-		}
-
-		if c.ordered {
-			if expected, ok = next.(*ExpectedExec); ok {
-				break
-			}
-			next.Unlock()
-			return nil, fmt.Errorf("call to exec query '%s' with args %+v, was not expected, next expectation is: %s", query, args, next)
-		}
-		if exec, ok := next.(*ExpectedExec); ok {
-			if err := exec.attemptMatch(query, args); err == nil {
-				expected = exec
-				break
-			}
-		}
-		next.Unlock()
-	}
-	if expected == nil {
-		msg := "call to exec '%s' query with args %+v was not expected"
-		if fulfilled == len(c.expected) {
-			msg = "all expectations were already fulfilled, " + msg
-		}
-		return nil, fmt.Errorf(msg, query, args)
-	}
-	defer expected.Unlock()
-
-	if !expected.queryMatches(query) {
-		return nil, fmt.Errorf("exec query '%s', does not match regex '%s'", query, expected.sqlRegex.String())
-	}
-
-	if err := expected.argsMatches(args); err != nil {
-		return nil, fmt.Errorf("exec query '%s', arguments do not match: %s", query, err)
-	}
-
-	expected.triggered = true
-	if expected.err != nil {
-		return nil, expected.err // mocked to return error
-	}
-
-	if expected.result == nil {
-		return nil, fmt.Errorf("exec query '%s' with args %+v, must return a database/sql/driver.result, but it was not set for expectation %T as %+v", query, args, expected, expected)
-	}
-
-	return expected, nil
-}
-
-func (c *sqlmock) ExpectExec(sqlRegexStr string) *ExpectedExec {
-	e := &ExpectedExec{}
-	sqlRegexStr = stripQuery(sqlRegexStr)
-	e.sqlRegex = regexp.MustCompile(sqlRegexStr)
-	c.expected = append(c.expected, e)
-	return e
-}
-
-// Prepare meets http://golang.org/pkg/database/sql/driver/#Conn interface
-func (c *sqlmock) Prepare(query string) (driver.Stmt, error) {
-	ex, err := c.prepare(query)
-	if err != nil {
-		return nil, err
-	}
-
-	time.Sleep(ex.delay)
-	return &statement{c, query, ex.closeErr}, nil
-}
-
-func (c *sqlmock) prepare(query string) (*ExpectedPrepare, error) {
-	var expected *ExpectedPrepare
-	var fulfilled int
-	var ok bool
-	for _, next := range c.expected {
-		next.Lock()
-		if next.fulfilled() {
-			next.Unlock()
-			fulfilled++
-			continue
-		}
-
-		if expected, ok = next.(*ExpectedPrepare); ok {
-			break
-		}
-
-		next.Unlock()
-		if c.ordered {
-			return nil, fmt.Errorf("call to Prepare statement with query '%s', was not expected, next expectation is: %s", query, next)
-		}
-	}
-
-	query = stripQuery(query)
-	if expected == nil {
-		msg := "call to Prepare '%s' query was not expected"
-		if fulfilled == len(c.expected) {
-			msg = "all expectations were already fulfilled, " + msg
-		}
-		return nil, fmt.Errorf(msg, query)
-	}
-	defer expected.Unlock()
-	if !expected.sqlRegex.MatchString(query) {
-		return nil, fmt.Errorf("query '%s', does not match regex [%s]", query, expected.sqlRegex.String())
-	}
-
-	expected.triggered = true
-	return expected, expected.err
-}
-
-func (c *sqlmock) ExpectPrepare(sqlRegexStr string) *ExpectedPrepare {
-	sqlRegexStr = stripQuery(sqlRegexStr)
-	e := &ExpectedPrepare{sqlRegex: regexp.MustCompile(sqlRegexStr), mock: c}
-	c.expected = append(c.expected, e)
-	return e
-}
-
-type namedValue struct {
-	Name    string
-	Ordinal int
-	Value   driver.Value
-}
-
-// Query meets http://golang.org/pkg/database/sql/driver/#Queryer
-func (c *sqlmock) Query(query string, args []driver.Value) (driver.Rows, error) {
-	namedArgs := make([]namedValue, len(args))
-	for i, v := range args {
-		namedArgs[i] = namedValue{
-			Ordinal: i + 1,
-			Value:   v,
-		}
-	}
-
-	ex, err := c.query(query, namedArgs)
-	if err != nil {
-		return nil, err
-	}
-
-	time.Sleep(ex.delay)
-	return ex.rows, nil
-}
-
-func (c *sqlmock) query(query string, args []namedValue) (*ExpectedQuery, error) {
-	query = stripQuery(query)
-	var expected *ExpectedQuery
-	var fulfilled int
-	var ok bool
-	for _, next := range c.expected {
-		next.Lock()
-		if next.fulfilled() {
-			next.Unlock()
-			fulfilled++
-			continue
-		}
-
-		if c.ordered {
-			if expected, ok = next.(*ExpectedQuery); ok {
-				break
-			}
-			next.Unlock()
-			return nil, fmt.Errorf("call to query '%s' with args %+v, was not expected, next expectation is: %s", query, args, next)
-		}
-		if qr, ok := next.(*ExpectedQuery); ok {
-			if err := qr.attemptMatch(query, args); err == nil {
-				expected = qr
-				break
-			}
-		}
-		next.Unlock()
-	}
-
-	if expected == nil {
-		msg := "call to query '%s' with args %+v was not expected"
-		if fulfilled == len(c.expected) {
-			msg = "all expectations were already fulfilled, " + msg
-		}
-		return nil, fmt.Errorf(msg, query, args)
-	}
-
-	defer expected.Unlock()
-
-	if !expected.queryMatches(query) {
-		return nil, fmt.Errorf("query '%s', does not match regex [%s]", query, expected.sqlRegex.String())
-	}
-
-	if err := expected.argsMatches(args); err != nil {
-		return nil, fmt.Errorf("exec query '%s', arguments do not match: %s", query, err)
-	}
-
-	expected.triggered = true
-	if expected.err != nil {
-		return nil, expected.err // mocked to return error
-	}
-
-	if expected.rows == nil {
-		return nil, fmt.Errorf("query '%s' with args %+v, must return a database/sql/driver.rows, but it was not set for expectation %T as %+v", query, args, expected, expected)
-	}
-	return expected, nil
-}
-
-func (c *sqlmock) ExpectQuery(sqlRegexStr string) *ExpectedQuery {
-	e := &ExpectedQuery{}
-	sqlRegexStr = stripQuery(sqlRegexStr)
-	e.sqlRegex = regexp.MustCompile(sqlRegexStr)
-	c.expected = append(c.expected, e)
-	return e
-}
-
-func (c *sqlmock) ExpectCommit() *ExpectedCommit {
-	e := &ExpectedCommit{}
-	c.expected = append(c.expected, e)
-	return e
-}
-
-func (c *sqlmock) ExpectRollback() *ExpectedRollback {
-	e := &ExpectedRollback{}
-	c.expected = append(c.expected, e)
-	return e
-}
-
-// Commit meets http://golang.org/pkg/database/sql/driver/#Tx
-func (c *sqlmock) Commit() error {
-	var expected *ExpectedCommit
-	var fulfilled int
-	var ok bool
-	for _, next := range c.expected {
-		next.Lock()
-		if next.fulfilled() {
-			next.Unlock()
-			fulfilled++
-			continue
-		}
-
-		if expected, ok = next.(*ExpectedCommit); ok {
-			break
-		}
-
-		next.Unlock()
-		if c.ordered {
-			return fmt.Errorf("call to commit transaction, was not expected, next expectation is: %s", next)
-		}
-	}
-	if expected == nil {
-		msg := "call to commit transaction was not expected"
-		if fulfilled == len(c.expected) {
-			msg = "all expectations were already fulfilled, " + msg
-		}
-		return fmt.Errorf(msg)
-	}
-
-	expected.triggered = true
-	expected.Unlock()
-	return expected.err
-}
-
-// Rollback meets http://golang.org/pkg/database/sql/driver/#Tx
-func (c *sqlmock) Rollback() error {
-	var expected *ExpectedRollback
-	var fulfilled int
-	var ok bool
-	for _, next := range c.expected {
-		next.Lock()
-		if next.fulfilled() {
-			next.Unlock()
-			fulfilled++
-			continue
-		}
-
-		if expected, ok = next.(*ExpectedRollback); ok {
-			break
-		}
-
-		next.Unlock()
-		if c.ordered {
-			return fmt.Errorf("call to rollback transaction, was not expected, next expectation is: %s", next)
-		}
-	}
-	if expected == nil {
-		msg := "call to rollback transaction was not expected"
-		if fulfilled == len(c.expected) {
-			msg = "all expectations were already fulfilled, " + msg
-		}
-		return fmt.Errorf(msg)
-	}
-
-	expected.triggered = true
-	expected.Unlock()
-	return expected.err
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18.go
deleted file mode 100644
index c49429c..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18.go
+++ /dev/null
@@ -1,101 +0,0 @@
-// +build go1.8
-
-package sqlmock
-
-import (
-	"context"
-	"database/sql/driver"
-	"errors"
-	"time"
-)
-
-var ErrCancelled = errors.New("canceling query due to user request")
-
-// Implement the "QueryerContext" interface
-func (c *sqlmock) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
-	namedArgs := make([]namedValue, len(args))
-	for i, nv := range args {
-		namedArgs[i] = namedValue(nv)
-	}
-
-	ex, err := c.query(query, namedArgs)
-	if err != nil {
-		return nil, err
-	}
-
-	select {
-	case <-time.After(ex.delay):
-		return ex.rows, nil
-	case <-ctx.Done():
-		return nil, ErrCancelled
-	}
-}
-
-// Implement the "ExecerContext" interface
-func (c *sqlmock) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
-	namedArgs := make([]namedValue, len(args))
-	for i, nv := range args {
-		namedArgs[i] = namedValue(nv)
-	}
-
-	ex, err := c.exec(query, namedArgs)
-	if err != nil {
-		return nil, err
-	}
-
-	select {
-	case <-time.After(ex.delay):
-		return ex.result, nil
-	case <-ctx.Done():
-		return nil, ErrCancelled
-	}
-}
-
-// Implement the "ConnBeginTx" interface
-func (c *sqlmock) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
-	ex, err := c.begin()
-	if err != nil {
-		return nil, err
-	}
-
-	select {
-	case <-time.After(ex.delay):
-		return c, nil
-	case <-ctx.Done():
-		return nil, ErrCancelled
-	}
-}
-
-// Implement the "ConnPrepareContext" interface
-func (c *sqlmock) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
-	ex, err := c.prepare(query)
-	if err != nil {
-		return nil, err
-	}
-
-	select {
-	case <-time.After(ex.delay):
-		return &statement{c, query, ex.closeErr}, nil
-	case <-ctx.Done():
-		return nil, ErrCancelled
-	}
-}
-
-// Implement the "Pinger" interface
-// for now we do not have a Ping expectation
-// may be something for the future
-func (c *sqlmock) Ping(ctx context.Context) error {
-	return nil
-}
-
-// Implement the "StmtExecContext" interface
-func (stmt *statement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
-	return stmt.conn.ExecContext(ctx, stmt.query, args)
-}
-
-// Implement the "StmtQueryContext" interface
-func (stmt *statement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
-	return stmt.conn.QueryContext(ctx, stmt.query, args)
-}
-
-// @TODO maybe add ExpectedBegin.WithOptions(driver.TxOptions)

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18_test.go
deleted file mode 100644
index 9eadcb5..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_go18_test.go
+++ /dev/null
@@ -1,426 +0,0 @@
-// +build go1.8
-
-package sqlmock
-
-import (
-	"context"
-	"database/sql"
-	"testing"
-	"time"
-)
-
-func TestContextExecCancel(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectExec("DELETE FROM users").
-		WillDelayFor(time.Second).
-		WillReturnResult(NewResult(1, 1))
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	_, err = db.ExecContext(ctx, "DELETE FROM users")
-	if err == nil {
-		t.Error("error was expected, but there was none")
-	}
-
-	if err != ErrCancelled {
-		t.Errorf("was expecting cancel error, but got: %v", err)
-	}
-
-	_, err = db.ExecContext(ctx, "DELETE FROM users")
-	if err != context.Canceled {
-		t.Error("error was expected since context was already done, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestPreparedStatementContextExecCancel(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectPrepare("DELETE FROM users").
-		ExpectExec().
-		WillDelayFor(time.Second).
-		WillReturnResult(NewResult(1, 1))
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	stmt, err := db.Prepare("DELETE FROM users")
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	_, err = stmt.ExecContext(ctx)
-	if err == nil {
-		t.Error("error was expected, but there was none")
-	}
-
-	if err != ErrCancelled {
-		t.Errorf("was expecting cancel error, but got: %v", err)
-	}
-
-	_, err = stmt.ExecContext(ctx)
-	if err != context.Canceled {
-		t.Error("error was expected since context was already done, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextExecWithNamedArg(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectExec("DELETE FROM users").
-		WithArgs(sql.Named("id", 5)).
-		WillDelayFor(time.Second).
-		WillReturnResult(NewResult(1, 1))
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	_, err = db.ExecContext(ctx, "DELETE FROM users WHERE id = :id", sql.Named("id", 5))
-	if err == nil {
-		t.Error("error was expected, but there was none")
-	}
-
-	if err != ErrCancelled {
-		t.Errorf("was expecting cancel error, but got: %v", err)
-	}
-
-	_, err = db.ExecContext(ctx, "DELETE FROM users WHERE id = :id", sql.Named("id", 5))
-	if err != context.Canceled {
-		t.Error("error was expected since context was already done, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextExec(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectExec("DELETE FROM users").
-		WillReturnResult(NewResult(1, 1))
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	res, err := db.ExecContext(ctx, "DELETE FROM users")
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	affected, err := res.RowsAffected()
-	if affected != 1 {
-		t.Errorf("expected affected rows 1, but got %v", affected)
-	}
-
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextQueryCancel(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
-
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
-		WithArgs(5).
-		WillDelayFor(time.Second).
-		WillReturnRows(rs)
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	_, err = db.QueryContext(ctx, "SELECT id, title FROM articles WHERE id = ?", 5)
-	if err == nil {
-		t.Error("error was expected, but there was none")
-	}
-
-	if err != ErrCancelled {
-		t.Errorf("was expecting cancel error, but got: %v", err)
-	}
-
-	_, err = db.QueryContext(ctx, "SELECT id, title FROM articles WHERE id = ?", 5)
-	if err != context.Canceled {
-		t.Error("error was expected since context was already done, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestPreparedStatementContextQueryCancel(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
-
-	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?").
-		ExpectQuery().
-		WithArgs(5).
-		WillDelayFor(time.Second).
-		WillReturnRows(rs)
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	stmt, err := db.Prepare("SELECT id, title FROM articles WHERE id = ?")
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	_, err = stmt.QueryContext(ctx, 5)
-	if err == nil {
-		t.Error("error was expected, but there was none")
-	}
-
-	if err != ErrCancelled {
-		t.Errorf("was expecting cancel error, but got: %v", err)
-	}
-
-	_, err = stmt.QueryContext(ctx, 5)
-	if err != context.Canceled {
-		t.Error("error was expected since context was already done, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextQuery(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
-
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id =").
-		WithArgs(sql.Named("id", 5)).
-		WillDelayFor(time.Millisecond * 3).
-		WillReturnRows(rs)
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	rows, err := db.QueryContext(ctx, "SELECT id, title FROM articles WHERE id = :id", sql.Named("id", 5))
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	if !rows.Next() {
-		t.Error("expected one row, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextBeginCancel(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectBegin().WillDelayFor(time.Second)
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	_, err = db.BeginTx(ctx, nil)
-	if err == nil {
-		t.Error("error was expected, but there was none")
-	}
-
-	if err != ErrCancelled {
-		t.Errorf("was expecting cancel error, but got: %v", err)
-	}
-
-	_, err = db.BeginTx(ctx, nil)
-	if err != context.Canceled {
-		t.Error("error was expected since context was already done, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextBegin(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectBegin().WillDelayFor(time.Millisecond * 3)
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	tx, err := db.BeginTx(ctx, nil)
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	if tx == nil {
-		t.Error("expected tx, but there was nil")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextPrepareCancel(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectPrepare("SELECT").WillDelayFor(time.Second)
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	_, err = db.PrepareContext(ctx, "SELECT")
-	if err == nil {
-		t.Error("error was expected, but there was none")
-	}
-
-	if err != ErrCancelled {
-		t.Errorf("was expecting cancel error, but got: %v", err)
-	}
-
-	_, err = db.PrepareContext(ctx, "SELECT")
-	if err != context.Canceled {
-		t.Error("error was expected since context was already done, but there was none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestContextPrepare(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectPrepare("SELECT").WillDelayFor(time.Millisecond * 3)
-
-	ctx, cancel := context.WithCancel(context.Background())
-
-	go func() {
-		time.Sleep(time.Millisecond * 10)
-		cancel()
-	}()
-
-	stmt, err := db.PrepareContext(ctx, "SELECT")
-	if err != nil {
-		t.Errorf("error was not expected, but got: %v", err)
-	}
-
-	if stmt == nil {
-		t.Error("expected stmt, but there was nil")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_test.go
deleted file mode 100644
index fe4924b..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/sqlmock_test.go
+++ /dev/null
@@ -1,998 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql"
-	"fmt"
-	"strconv"
-	"sync"
-	"testing"
-	"time"
-)
-
-func cancelOrder(db *sql.DB, orderID int) error {
-	tx, _ := db.Begin()
-	_, _ = tx.Query("SELECT * FROM orders {0} FOR UPDATE", orderID)
-	err := tx.Rollback()
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-func Example() {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	// columns to be used for result
-	columns := []string{"id", "status"}
-	// expect transaction begin
-	mock.ExpectBegin()
-	// expect query to fetch order, match it with regexp
-	mock.ExpectQuery("SELECT (.+) FROM orders (.+) FOR UPDATE").
-		WithArgs(1).
-		WillReturnRows(NewRows(columns).AddRow(1, 1))
-	// expect transaction rollback, since order status is "cancelled"
-	mock.ExpectRollback()
-
-	// run the cancel order function
-	someOrderID := 1
-	// call a function which executes expected database operations
-	err = cancelOrder(db, someOrderID)
-	if err != nil {
-		fmt.Printf("unexpected error: %s", err)
-		return
-	}
-
-	// ensure all expectations have been met
-	if err = mock.ExpectationsWereMet(); err != nil {
-		fmt.Printf("unmet expectation error: %s", err)
-	}
-	// Output:
-}
-
-func TestIssue14EscapeSQL(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-	mock.ExpectExec("INSERT INTO mytable\\(a, b\\)").
-		WithArgs("A", "B").
-		WillReturnResult(NewResult(1, 1))
-
-	_, err = db.Exec("INSERT INTO mytable(a, b) VALUES (?, ?)", "A", "B")
-	if err != nil {
-		t.Errorf("error '%s' was not expected, while inserting a row", err)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-// test the case when db is not triggered and expectations
-// are not asserted on close
-func TestIssue4(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectQuery("some sql query which will not be called").
-		WillReturnRows(NewRows([]string{"id"}))
-
-	if err := mock.ExpectationsWereMet(); err == nil {
-		t.Errorf("was expecting an error since query was not triggered")
-	}
-}
-
-func TestMockQuery(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
-
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
-		WithArgs(5).
-		WillReturnRows(rs)
-
-	rows, err := db.Query("SELECT (.+) FROM articles WHERE id = ?", 5)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
-	}
-
-	defer func() {
-		if er := rows.Close(); er != nil {
-			t.Error("Unexpected error while trying to close rows")
-		}
-	}()
-
-	if !rows.Next() {
-		t.Error("it must have had one row as result, but got empty result set instead")
-	}
-
-	var id int
-	var title string
-
-	err = rows.Scan(&id, &title)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while trying to scan row", err)
-	}
-
-	if id != 5 {
-		t.Errorf("expected mocked id to be 5, but got %d instead", id)
-	}
-
-	if title != "hello world" {
-		t.Errorf("expected mocked title to be 'hello world', but got '%s' instead", title)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestMockQueryTypes(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	columns := []string{"id", "timestamp", "sold"}
-
-	timestamp := time.Now()
-	rs := NewRows(columns)
-	rs.AddRow(5, timestamp, true)
-
-	mock.ExpectQuery("SELECT (.+) FROM sales WHERE id = ?").
-		WithArgs(5).
-		WillReturnRows(rs)
-
-	rows, err := db.Query("SELECT (.+) FROM sales WHERE id = ?", 5)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
-	}
-	defer func() {
-		if er := rows.Close(); er != nil {
-			t.Error("Unexpected error while trying to close rows")
-		}
-	}()
-	if !rows.Next() {
-		t.Error("it must have had one row as result, but got empty result set instead")
-	}
-
-	var id int
-	var time time.Time
-	var sold bool
-
-	err = rows.Scan(&id, &time, &sold)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while trying to scan row", err)
-	}
-
-	if id != 5 {
-		t.Errorf("expected mocked id to be 5, but got %d instead", id)
-	}
-
-	if time != timestamp {
-		t.Errorf("expected mocked time to be %s, but got '%s' instead", timestamp, time)
-	}
-
-	if sold != true {
-		t.Errorf("expected mocked boolean to be true, but got %v instead", sold)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestTransactionExpectations(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	// begin and commit
-	mock.ExpectBegin()
-	mock.ExpectCommit()
-
-	tx, err := db.Begin()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when beginning a transaction", err)
-	}
-
-	err = tx.Commit()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when committing a transaction", err)
-	}
-
-	// begin and rollback
-	mock.ExpectBegin()
-	mock.ExpectRollback()
-
-	tx, err = db.Begin()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when beginning a transaction", err)
-	}
-
-	err = tx.Rollback()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when rolling back a transaction", err)
-	}
-
-	// begin with an error
-	mock.ExpectBegin().WillReturnError(fmt.Errorf("some err"))
-
-	tx, err = db.Begin()
-	if err == nil {
-		t.Error("an error was expected when beginning a transaction, but got none")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestPrepareExpectations(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?")
-
-	stmt, err := db.Prepare("SELECT (.+) FROM articles WHERE id = ?")
-	if err != nil {
-		t.Errorf("error '%s' was not expected while creating a prepared statement", err)
-	}
-	if stmt == nil {
-		t.Errorf("stmt was expected while creating a prepared statement")
-	}
-
-	// expect something else, w/o ExpectPrepare()
-	var id int
-	var title string
-	rs := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
-
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
-		WithArgs(5).
-		WillReturnRows(rs)
-
-	err = stmt.QueryRow(5).Scan(&id, &title)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
-	}
-
-	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?").
-		WillReturnError(fmt.Errorf("Some DB error occurred"))
-
-	stmt, err = db.Prepare("SELECT id FROM articles WHERE id = ?")
-	if err == nil {
-		t.Error("error was expected while creating a prepared statement")
-	}
-	if stmt != nil {
-		t.Errorf("stmt was not expected while creating a prepared statement returning error")
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestPreparedQueryExecutions(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?")
-
-	rs1 := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
-		WithArgs(5).
-		WillReturnRows(rs1)
-
-	rs2 := NewRows([]string{"id", "title"}).FromCSVString("2,whoop")
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
-		WithArgs(2).
-		WillReturnRows(rs2)
-
-	stmt, err := db.Prepare("SELECT id, title FROM articles WHERE id = ?")
-	if err != nil {
-		t.Errorf("error '%s' was not expected while creating a prepared statement", err)
-	}
-
-	var id int
-	var title string
-	err = stmt.QueryRow(5).Scan(&id, &title)
-	if err != nil {
-		t.Errorf("error '%s' was not expected querying row from statement and scanning", err)
-	}
-
-	if id != 5 {
-		t.Errorf("expected mocked id to be 5, but got %d instead", id)
-	}
-
-	if title != "hello world" {
-		t.Errorf("expected mocked title to be 'hello world', but got '%s' instead", title)
-	}
-
-	err = stmt.QueryRow(2).Scan(&id, &title)
-	if err != nil {
-		t.Errorf("error '%s' was not expected querying row from statement and scanning", err)
-	}
-
-	if id != 2 {
-		t.Errorf("expected mocked id to be 2, but got %d instead", id)
-	}
-
-	if title != "whoop" {
-		t.Errorf("expected mocked title to be 'whoop', but got '%s' instead", title)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestUnexpectedOperations(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?")
-	stmt, err := db.Prepare("SELECT id, title FROM articles WHERE id = ?")
-	if err != nil {
-		t.Errorf("error '%s' was not expected while creating a prepared statement", err)
-	}
-
-	var id int
-	var title string
-
-	err = stmt.QueryRow(5).Scan(&id, &title)
-	if err == nil {
-		t.Error("error was expected querying row, since there was no such expectation")
-	}
-
-	mock.ExpectRollback()
-
-	if err := mock.ExpectationsWereMet(); err == nil {
-		t.Errorf("was expecting an error since query was not triggered")
-	}
-}
-
-func TestWrongExpectations(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectBegin()
-
-	rs1 := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
-		WithArgs(5).
-		WillReturnRows(rs1)
-
-	mock.ExpectCommit().WillReturnError(fmt.Errorf("deadlock occurred"))
-	mock.ExpectRollback() // won't be triggered
-
-	var id int
-	var title string
-
-	err = db.QueryRow("SELECT id, title FROM articles WHERE id = ? FOR UPDATE", 5).Scan(&id, &title)
-	if err == nil {
-		t.Error("error was expected while querying row, since there begin transaction expectation is not fulfilled")
-	}
-
-	// lets go around and start transaction
-	tx, err := db.Begin()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when beginning a transaction", err)
-	}
-
-	err = db.QueryRow("SELECT id, title FROM articles WHERE id = ? FOR UPDATE", 5).Scan(&id, &title)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while querying row, since transaction was started", err)
-	}
-
-	err = tx.Commit()
-	if err == nil {
-		t.Error("a deadlock error was expected when committing a transaction", err)
-	}
-
-	if err := mock.ExpectationsWereMet(); err == nil {
-		t.Errorf("was expecting an error since query was not triggered")
-	}
-}
-
-func TestExecExpectations(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	result := NewResult(1, 1)
-	mock.ExpectExec("^INSERT INTO articles").
-		WithArgs("hello").
-		WillReturnResult(result)
-
-	res, err := db.Exec("INSERT INTO articles (title) VALUES (?)", "hello")
-	if err != nil {
-		t.Errorf("error '%s' was not expected, while inserting a row", err)
-	}
-
-	id, err := res.LastInsertId()
-	if err != nil {
-		t.Errorf("error '%s' was not expected, while getting a last insert id", err)
-	}
-
-	affected, err := res.RowsAffected()
-	if err != nil {
-		t.Errorf("error '%s' was not expected, while getting affected rows", err)
-	}
-
-	if id != 1 {
-		t.Errorf("expected last insert id to be 1, but got %d instead", id)
-	}
-
-	if affected != 1 {
-		t.Errorf("expected affected rows to be 1, but got %d instead", affected)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestRowBuilderAndNilTypes(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs := NewRows([]string{"id", "active", "created", "status"}).
-		AddRow(1, true, time.Now(), 5).
-		AddRow(2, false, nil, nil)
-
-	mock.ExpectQuery("SELECT (.+) FROM sales").WillReturnRows(rs)
-
-	rows, err := db.Query("SELECT * FROM sales")
-	if err != nil {
-		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
-	}
-	defer func() {
-		if er := rows.Close(); er != nil {
-			t.Error("Unexpected error while trying to close rows")
-		}
-	}()
-
-	// NullTime and NullInt are used from stubs_test.go
-	var (
-		id      int
-		active  bool
-		created NullTime
-		status  NullInt
-	)
-
-	if !rows.Next() {
-		t.Error("it must have had row in rows, but got empty result set instead")
-	}
-
-	err = rows.Scan(&id, &active, &created, &status)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while trying to scan row", err)
-	}
-
-	if id != 1 {
-		t.Errorf("expected mocked id to be 1, but got %d instead", id)
-	}
-
-	if !active {
-		t.Errorf("expected 'active' to be 'true', but got '%v' instead", active)
-	}
-
-	if !created.Valid {
-		t.Errorf("expected 'created' to be valid, but it %+v is not", created)
-	}
-
-	if !status.Valid {
-		t.Errorf("expected 'status' to be valid, but it %+v is not", status)
-	}
-
-	if status.Integer != 5 {
-		t.Errorf("expected 'status' to be '5', but got '%d'", status.Integer)
-	}
-
-	// test second row
-	if !rows.Next() {
-		t.Error("it must have had row in rows, but got empty result set instead")
-	}
-
-	err = rows.Scan(&id, &active, &created, &status)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while trying to scan row", err)
-	}
-
-	if id != 2 {
-		t.Errorf("expected mocked id to be 2, but got %d instead", id)
-	}
-
-	if active {
-		t.Errorf("expected 'active' to be 'false', but got '%v' instead", active)
-	}
-
-	if created.Valid {
-		t.Errorf("expected 'created' to be invalid, but it %+v is not", created)
-	}
-
-	if status.Valid {
-		t.Errorf("expected 'status' to be invalid, but it %+v is not", status)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestArgumentReflectValueTypeError(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs := NewRows([]string{"id"}).AddRow(1)
-
-	mock.ExpectQuery("SELECT (.+) FROM sales").WithArgs(5.5).WillReturnRows(rs)
-
-	_, err = db.Query("SELECT * FROM sales WHERE x = ?", 5)
-	if err == nil {
-		t.Error("Expected error, but got none")
-	}
-}
-
-func TestGoroutineExecutionWithUnorderedExpectationMatching(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	// note this line is important for unordered expectation matching
-	mock.MatchExpectationsInOrder(false)
-
-	result := NewResult(1, 1)
-
-	mock.ExpectExec("^UPDATE one").WithArgs("one").WillReturnResult(result)
-	mock.ExpectExec("^UPDATE two").WithArgs("one", "two").WillReturnResult(result)
-	mock.ExpectExec("^UPDATE three").WithArgs("one", "two", "three").WillReturnResult(result)
-
-	var wg sync.WaitGroup
-	queries := map[string][]interface{}{
-		"one":   []interface{}{"one"},
-		"two":   []interface{}{"one", "two"},
-		"three": []interface{}{"one", "two", "three"},
-	}
-
-	wg.Add(len(queries))
-	for table, args := range queries {
-		go func(tbl string, a []interface{}) {
-			if _, err := db.Exec("UPDATE "+tbl, a...); err != nil {
-				t.Errorf("error was not expected: %s", err)
-			}
-			wg.Done()
-		}(table, args)
-	}
-
-	wg.Wait()
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func ExampleSqlmock_goroutines() {
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("failed to open sqlmock database:", err)
-	}
-	defer db.Close()
-
-	// note this line is important for unordered expectation matching
-	mock.MatchExpectationsInOrder(false)
-
-	result := NewResult(1, 1)
-
-	mock.ExpectExec("^UPDATE one").WithArgs("one").WillReturnResult(result)
-	mock.ExpectExec("^UPDATE two").WithArgs("one", "two").WillReturnResult(result)
-	mock.ExpectExec("^UPDATE three").WithArgs("one", "two", "three").WillReturnResult(result)
-
-	var wg sync.WaitGroup
-	queries := map[string][]interface{}{
-		"one":   []interface{}{"one"},
-		"two":   []interface{}{"one", "two"},
-		"three": []interface{}{"one", "two", "three"},
-	}
-
-	wg.Add(len(queries))
-	for table, args := range queries {
-		go func(tbl string, a []interface{}) {
-			if _, err := db.Exec("UPDATE "+tbl, a...); err != nil {
-				fmt.Println("error was not expected:", err)
-			}
-			wg.Done()
-		}(table, args)
-	}
-
-	wg.Wait()
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		fmt.Println("there were unfulfilled expections:", err)
-	}
-	// Output:
-}
-
-// False Positive - passes despite mismatched Exec
-// see #37 issue
-func TestRunExecsWithOrderedShouldNotMeetAllExpectations(t *testing.T) {
-	db, dbmock, _ := New()
-	dbmock.ExpectExec("THE FIRST EXEC")
-	dbmock.ExpectExec("THE SECOND EXEC")
-
-	_, _ = db.Exec("THE FIRST EXEC")
-	_, _ = db.Exec("THE WRONG EXEC")
-
-	err := dbmock.ExpectationsWereMet()
-	if err == nil {
-		t.Fatal("was expecting an error, but there wasn't any")
-	}
-}
-
-// False Positive - passes despite mismatched Exec
-// see #37 issue
-func TestRunQueriesWithOrderedShouldNotMeetAllExpectations(t *testing.T) {
-	db, dbmock, _ := New()
-	dbmock.ExpectQuery("THE FIRST QUERY")
-	dbmock.ExpectQuery("THE SECOND QUERY")
-
-	_, _ = db.Query("THE FIRST QUERY")
-	_, _ = db.Query("THE WRONG QUERY")
-
-	err := dbmock.ExpectationsWereMet()
-	if err == nil {
-		t.Fatal("was expecting an error, but there wasn't any")
-	}
-}
-
-func TestRunExecsWithExpectedErrorMeetsExpectations(t *testing.T) {
-	db, dbmock, _ := New()
-	dbmock.ExpectExec("THE FIRST EXEC").WillReturnError(fmt.Errorf("big bad bug"))
-	dbmock.ExpectExec("THE SECOND EXEC").WillReturnResult(NewResult(0, 0))
-
-	_, _ = db.Exec("THE FIRST EXEC")
-	_, _ = db.Exec("THE SECOND EXEC")
-
-	err := dbmock.ExpectationsWereMet()
-	if err != nil {
-		t.Fatalf("all expectations should be met: %s", err)
-	}
-}
-
-func TestRunQueryWithExpectedErrorMeetsExpectations(t *testing.T) {
-	db, dbmock, _ := New()
-	dbmock.ExpectQuery("THE FIRST QUERY").WillReturnError(fmt.Errorf("big bad bug"))
-	dbmock.ExpectQuery("THE SECOND QUERY").WillReturnRows(NewRows([]string{"col"}).AddRow(1))
-
-	_, _ = db.Query("THE FIRST QUERY")
-	_, _ = db.Query("THE SECOND QUERY")
-
-	err := dbmock.ExpectationsWereMet()
-	if err != nil {
-		t.Fatalf("all expectations should be met: %s", err)
-	}
-}
-
-func TestEmptyRowSet(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	rs := NewRows([]string{"id", "title"})
-
-	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
-		WithArgs(5).
-		WillReturnRows(rs)
-
-	rows, err := db.Query("SELECT (.+) FROM articles WHERE id = ?", 5)
-	if err != nil {
-		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
-	}
-
-	defer func() {
-		if er := rows.Close(); er != nil {
-			t.Error("Unexpected error while trying to close rows")
-		}
-	}()
-
-	if rows.Next() {
-		t.Error("expected no rows but got one")
-	}
-
-	err = mock.ExpectationsWereMet()
-	if err != nil {
-		t.Fatalf("all expectations should be met: %s", err)
-	}
-}
-
-// Based on issue #50
-func TestPrepareExpectationNotFulfilled(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectPrepare("^BADSELECT$")
-
-	if _, err := db.Prepare("SELECT"); err == nil {
-		t.Fatal("prepare should not match expected query string")
-	}
-
-	if err := mock.ExpectationsWereMet(); err == nil {
-		t.Errorf("was expecting an error, since prepared statement query does not match, but there was none")
-	}
-}
-
-func TestRollbackThrow(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	// columns to be used for result
-	columns := []string{"id", "status"}
-	// expect transaction begin
-	mock.ExpectBegin()
-	// expect query to fetch order, match it with regexp
-	mock.ExpectQuery("SELECT (.+) FROM orders (.+) FOR UPDATE").
-		WithArgs(1).
-		WillReturnRows(NewRows(columns).AddRow(1, 1))
-	// expect transaction rollback, since order status is "cancelled"
-	mock.ExpectRollback().WillReturnError(fmt.Errorf("rollback failed"))
-
-	// run the cancel order function
-	someOrderID := 1
-	// call a function which executes expected database operations
-	err = cancelOrder(db, someOrderID)
-	if err == nil {
-		t.Error("an error was expected when rolling back transaction, but got none")
-	}
-
-	// ensure all expectations have been met
-	if err = mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("unmet expectation error: %s", err)
-	}
-	// Output:
-}
-
-func TestUnexpectedCommit(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	mock.ExpectBegin()
-	tx, _ := db.Begin()
-	if err := tx.Commit(); err == nil {
-		t.Error("an error was expected when calling commit, but got none")
-	}
-}
-
-func TestUnexpectedCommitOrder(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	mock.ExpectBegin()
-	mock.ExpectRollback().WillReturnError(fmt.Errorf("Rollback failed"))
-	tx, _ := db.Begin()
-	if err := tx.Commit(); err == nil {
-		t.Error("an error was expected when calling commit, but got none")
-	}
-}
-
-func TestExpectedCommitOrder(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	mock.ExpectCommit().WillReturnError(fmt.Errorf("Commit failed"))
-	if _, err := db.Begin(); err == nil {
-		t.Error("an error was expected when calling begin, but got none")
-	}
-}
-
-func TestUnexpectedRollback(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	mock.ExpectBegin()
-	tx, _ := db.Begin()
-	if err := tx.Rollback(); err == nil {
-		t.Error("an error was expected when calling rollback, but got none")
-	}
-}
-
-func TestUnexpectedRollbackOrder(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	mock.ExpectBegin()
-
-	tx, _ := db.Begin()
-	if err := tx.Rollback(); err == nil {
-		t.Error("an error was expected when calling rollback, but got none")
-	}
-}
-
-func TestPrepareExec(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	defer db.Close()
-	mock.ExpectBegin()
-	ep := mock.ExpectPrepare("INSERT INTO ORDERS\\(ID, STATUS\\) VALUES \\(\\?, \\?\\)")
-	for i := 0; i < 3; i++ {
-		ep.ExpectExec().WillReturnResult(NewResult(1, 1))
-	}
-	mock.ExpectCommit()
-	tx, _ := db.Begin()
-	stmt, err := tx.Prepare("INSERT INTO ORDERS(ID, STATUS) VALUES (?, ?)")
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer stmt.Close()
-	for i := 0; i < 3; i++ {
-		_, err := stmt.Exec(i, "Hello"+strconv.Itoa(i))
-		if err != nil {
-			t.Fatal(err)
-		}
-	}
-	tx.Commit()
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestPrepareQuery(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	defer db.Close()
-	mock.ExpectBegin()
-	ep := mock.ExpectPrepare("SELECT ID, STATUS FROM ORDERS WHERE ID = \\?")
-	ep.ExpectQuery().WithArgs(101).WillReturnRows(NewRows([]string{"ID", "STATUS"}).AddRow(101, "Hello"))
-	mock.ExpectCommit()
-	tx, _ := db.Begin()
-	stmt, err := tx.Prepare("SELECT ID, STATUS FROM ORDERS WHERE ID = ?")
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer stmt.Close()
-	rows, err := stmt.Query(101)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer rows.Close()
-	for rows.Next() {
-		var (
-			id     int
-			status string
-		)
-		if rows.Scan(&id, &status); id != 101 || status != "Hello" {
-			t.Fatal("wrong query results")
-		}
-
-	}
-	tx.Commit()
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestExpectedCloseError(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	mock.ExpectClose().WillReturnError(fmt.Errorf("Close failed"))
-	if err := db.Close(); err == nil {
-		t.Error("an error was expected when calling close, but got none")
-	}
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestExpectedCloseOrder(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	defer db.Close()
-	mock.ExpectClose().WillReturnError(fmt.Errorf("Close failed"))
-	db.Begin()
-	if err := mock.ExpectationsWereMet(); err == nil {
-		t.Error("expected error on ExpectationsWereMet")
-	}
-}
-
-func TestExpectedBeginOrder(t *testing.T) {
-	// Open new mock database
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("error creating mock database")
-		return
-	}
-	mock.ExpectBegin().WillReturnError(fmt.Errorf("Begin failed"))
-	if err := db.Close(); err == nil {
-		t.Error("an error was expected when calling close, but got none")
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement.go
deleted file mode 100644
index df73740..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql/driver"
-)
-
-type statement struct {
-	conn  *sqlmock
-	query string
-	err   error
-}
-
-func (stmt *statement) Close() error {
-	return stmt.err
-}
-
-func (stmt *statement) NumInput() int {
-	return -1
-}
-
-func (stmt *statement) Exec(args []driver.Value) (driver.Result, error) {
-	return stmt.conn.Exec(stmt.query, args)
-}
-
-func (stmt *statement) Query(args []driver.Value) (driver.Rows, error) {
-	return stmt.conn.Query(stmt.query, args)
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement_test.go
deleted file mode 100644
index f951f63..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/statement_test.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// +build go1.6
-
-package sqlmock
-
-import (
-	"errors"
-	"testing"
-)
-
-func TestExpectedPreparedStatemtCloseError(t *testing.T) {
-	conn, mock, err := New()
-	if err != nil {
-		t.Fatal("failed to open sqlmock database:", err)
-	}
-
-	mock.ExpectBegin()
-	want := errors.New("STMT ERROR")
-	mock.ExpectPrepare("SELECT").WillReturnCloseError(want)
-
-	txn, err := conn.Begin()
-	if err != nil {
-		t.Fatal("unexpected error while opening transaction:", err)
-	}
-
-	stmt, err := txn.Prepare("SELECT")
-	if err != nil {
-		t.Fatal("unexpected error while preparing a statement:", err)
-	}
-
-	if err := stmt.Close(); err != want {
-		t.Fatalf("Got = %v, want = %v", err, want)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/stubs_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/stubs_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/stubs_test.go
deleted file mode 100644
index d3c6003..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/stubs_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql/driver"
-	"fmt"
-	"strconv"
-	"time"
-)
-
-type NullTime struct {
-	Time  time.Time
-	Valid bool // Valid is true if Time is not NULL
-}
-
-type NullInt struct {
-	Integer int
-	Valid   bool
-}
-
-// Satisfy sql.Scanner interface
-func (ni *NullInt) Scan(value interface{}) (err error) {
-	if value == nil {
-		ni.Integer, ni.Valid = 0, false
-		return
-	}
-
-	switch v := value.(type) {
-	case int, int8, int16, int32, int64:
-		ni.Integer, ni.Valid = v.(int), true
-		return
-	case []byte:
-		ni.Integer, err = strconv.Atoi(string(v))
-		ni.Valid = (err == nil)
-		return
-	case string:
-		ni.Integer, err = strconv.Atoi(v)
-		ni.Valid = (err == nil)
-		return
-	}
-
-	ni.Valid = false
-	return fmt.Errorf("Can't convert %T to integer", value)
-}
-
-// Satisfy sql.Valuer interface.
-func (ni NullInt) Value() (driver.Value, error) {
-	if !ni.Valid {
-		return nil, nil
-	}
-	return ni.Integer, nil
-}
-
-// Satisfy sql.Scanner interface
-func (nt *NullTime) Scan(value interface{}) (err error) {
-	if value == nil {
-		nt.Time, nt.Valid = time.Time{}, false
-		return
-	}
-
-	switch v := value.(type) {
-	case time.Time:
-		nt.Time, nt.Valid = v, true
-		return
-	}
-
-	nt.Valid = false
-	return fmt.Errorf("Can't convert %T to time.Time", value)
-}
-
-// Satisfy sql.Valuer interface.
-func (nt NullTime) Value() (driver.Value, error) {
-	if !nt.Valid {
-		return nil, nil
-	}
-	return nt.Time, nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util.go
deleted file mode 100644
index 072e380..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package sqlmock
-
-import (
-	"regexp"
-	"strings"
-)
-
-var re = regexp.MustCompile("\\s+")
-
-// strip out new lines and trim spaces
-func stripQuery(q string) (s string) {
-	return strings.TrimSpace(re.ReplaceAllString(q, " "))
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util_test.go
deleted file mode 100644
index c4b3974..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/util_test.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package sqlmock
-
-import (
-	"testing"
-)
-
-func TestQueryStringStripping(t *testing.T) {
-	assert := func(actual, expected string) {
-		if res := stripQuery(actual); res != expected {
-			t.Errorf("Expected '%s' to be '%s', but got '%s'", actual, expected, res)
-		}
-	}
-
-	assert(" SELECT 1", "SELECT 1")
-	assert("SELECT   1 FROM   d", "SELECT 1 FROM d")
-	assert(`
-    SELECT c
-    FROM D
-`, "SELECT c FROM D")
-	assert("UPDATE  (.+) SET  ", "UPDATE (.+) SET")
-}


[9/9] incubator-trafficcontrol git commit: This closes #806.

Posted by da...@apache.org.
This closes #806.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/3598cffd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/3598cffd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/3598cffd

Branch: refs/heads/master
Commit: 3598cffd54f752b9efda72f89006318f91997586
Parents: 13fd715
Author: Dan Kirkwood <da...@gmail.com>
Authored: Mon Aug 14 14:39:01 2017 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Mon Aug 14 14:39:01 2017 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------



[8/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Posted by da...@apache.org.
added lib/pq to the vendor dir and renamed the go-sqlmock to its version


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/13fd7151
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/13fd7151
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/13fd7151

Branch: refs/heads/master
Commit: 13fd7151f992081da8cf5b79d262fba5df5de2db
Parents: 9c8f5b5
Author: Dewayne Richardson <de...@apache.org>
Authored: Mon Aug 14 13:30:56 2017 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Mon Aug 14 14:38:45 2017 -0600

----------------------------------------------------------------------
 .../vendor/github.com/lib/pq/.travis.sh         |   73 +
 .../vendor/github.com/lib/pq/.travis.yml        |   45 +
 .../vendor/github.com/lib/pq/CONTRIBUTING.md    |   29 +
 .../vendor/github.com/lib/pq/LICENSE.md         |    8 +
 .../vendor/github.com/lib/pq/README.md          |  105 +
 .../vendor/github.com/lib/pq/array.go           |  756 ++++++++
 .../vendor/github.com/lib/pq/array_test.go      | 1317 +++++++++++++
 .../vendor/github.com/lib/pq/bench_test.go      |  435 +++++
 .../vendor/github.com/lib/pq/buf.go             |   91 +
 .../vendor/github.com/lib/pq/certs/README       |    3 +
 .../github.com/lib/pq/certs/bogus_root.crt      |   19 +
 .../github.com/lib/pq/certs/postgresql.crt      |   69 +
 .../github.com/lib/pq/certs/postgresql.key      |   15 +
 .../vendor/github.com/lib/pq/certs/root.crt     |   24 +
 .../vendor/github.com/lib/pq/certs/server.crt   |   81 +
 .../vendor/github.com/lib/pq/certs/server.key   |   27 +
 .../vendor/github.com/lib/pq/conn.go            | 1821 ++++++++++++++++++
 .../vendor/github.com/lib/pq/conn_go18.go       |  128 ++
 .../vendor/github.com/lib/pq/conn_test.go       | 1614 ++++++++++++++++
 .../vendor/github.com/lib/pq/copy.go            |  282 +++
 .../vendor/github.com/lib/pq/copy_test.go       |  465 +++++
 .../vendor/github.com/lib/pq/doc.go             |  235 +++
 .../vendor/github.com/lib/pq/encode.go          |  595 ++++++
 .../vendor/github.com/lib/pq/encode_test.go     |  758 ++++++++
 .../vendor/github.com/lib/pq/error.go           |  508 +++++
 .../vendor/github.com/lib/pq/go18_test.go       |  319 +++
 .../vendor/github.com/lib/pq/hstore/hstore.go   |  118 ++
 .../github.com/lib/pq/hstore/hstore_test.go     |  148 ++
 .../vendor/github.com/lib/pq/issues_test.go     |   26 +
 .../github.com/lib/pq/listen_example/doc.go     |   96 +
 .../vendor/github.com/lib/pq/notify.go          |  782 ++++++++
 .../vendor/github.com/lib/pq/notify_test.go     |  564 ++++++
 .../vendor/github.com/lib/pq/oid/doc.go         |    6 +
 .../vendor/github.com/lib/pq/oid/gen.go         |   74 +
 .../vendor/github.com/lib/pq/oid/types.go       |  173 ++
 .../vendor/github.com/lib/pq/ssl.go             |  158 ++
 .../vendor/github.com/lib/pq/ssl_go1.7.go       |   14 +
 .../vendor/github.com/lib/pq/ssl_permissions.go |   20 +
 .../github.com/lib/pq/ssl_renegotiation.go      |    8 +
 .../vendor/github.com/lib/pq/ssl_test.go        |  279 +++
 .../vendor/github.com/lib/pq/ssl_windows.go     |    9 +
 .../vendor/github.com/lib/pq/url.go             |   76 +
 .../vendor/github.com/lib/pq/url_test.go        |   66 +
 .../vendor/github.com/lib/pq/user_posix.go      |   24 +
 .../vendor/github.com/lib/pq/user_windows.go    |   27 +
 .../vendor/github.com/lib/pq/uuid.go            |   23 +
 .../vendor/github.com/lib/pq/uuid_test.go       |   46 +
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/LICENSE     |   28 +
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/README.md   |  223 +++
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/argument.go |   24 +
 .../DATA-DOG/go-sqlmock.v1/argument_test.go     |   58 +
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/driver.go   |   78 +
 .../DATA-DOG/go-sqlmock.v1/driver_test.go       |  112 ++
 .../go-sqlmock.v1/examples/basic/basic.go       |   40 +
 .../go-sqlmock.v1/examples/basic/basic_test.go  |   58 +
 .../go-sqlmock.v1/examples/blog/blog.go         |   81 +
 .../go-sqlmock.v1/examples/blog/blog_test.go    |  102 +
 .../DATA-DOG/go-sqlmock.v1/examples/doc.go      |    1 +
 .../go-sqlmock.v1/examples/orders/orders.go     |  121 ++
 .../examples/orders/orders_test.go              |  108 ++
 .../DATA-DOG/go-sqlmock.v1/expectations.go      |  344 ++++
 .../go-sqlmock.v1/expectations_before_go18.go   |   52 +
 .../DATA-DOG/go-sqlmock.v1/expectations_go18.go |   66 +
 .../go-sqlmock.v1/expectations_go18_test.go     |   64 +
 .../DATA-DOG/go-sqlmock.v1/expectations_test.go |  154 ++
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/result.go   |   39 +
 .../DATA-DOG/go-sqlmock.v1/result_test.go       |   62 +
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/rows.go     |  144 ++
 .../DATA-DOG/go-sqlmock.v1/rows_go18.go         |   20 +
 .../DATA-DOG/go-sqlmock.v1/rows_go18_test.go    |   92 +
 .../DATA-DOG/go-sqlmock.v1/rows_test.go         |  265 +++
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock.go  |  525 +++++
 .../DATA-DOG/go-sqlmock.v1/sqlmock_go18.go      |  101 +
 .../DATA-DOG/go-sqlmock.v1/sqlmock_go18_test.go |  426 ++++
 .../DATA-DOG/go-sqlmock.v1/sqlmock_test.go      |  998 ++++++++++
 .../DATA-DOG/go-sqlmock.v1/statement.go         |   27 +
 .../DATA-DOG/go-sqlmock.v1/statement_test.go    |   33 +
 .../DATA-DOG/go-sqlmock.v1/stubs_test.go        |   76 +
 .../gopkg.in/DATA-DOG/go-sqlmock.v1/util.go     |   13 +
 .../DATA-DOG/go-sqlmock.v1/util_test.go         |   21 +
 .../vendor/gopkg.in/DATA-DOG/go-sqlmock/LICENSE |   28 -
 .../gopkg.in/DATA-DOG/go-sqlmock/README.md      |  223 ---
 .../gopkg.in/DATA-DOG/go-sqlmock/argument.go    |   24 -
 .../DATA-DOG/go-sqlmock/argument_test.go        |   58 -
 .../gopkg.in/DATA-DOG/go-sqlmock/driver.go      |   78 -
 .../gopkg.in/DATA-DOG/go-sqlmock/driver_test.go |  112 --
 .../DATA-DOG/go-sqlmock/examples/basic/basic.go |   40 -
 .../go-sqlmock/examples/basic/basic_test.go     |   58 -
 .../DATA-DOG/go-sqlmock/examples/blog/blog.go   |   81 -
 .../go-sqlmock/examples/blog/blog_test.go       |  102 -
 .../DATA-DOG/go-sqlmock/examples/doc.go         |    1 -
 .../go-sqlmock/examples/orders/orders.go        |  121 --
 .../go-sqlmock/examples/orders/orders_test.go   |  108 --
 .../DATA-DOG/go-sqlmock/expectations.go         |  344 ----
 .../go-sqlmock/expectations_before_go18.go      |   52 -
 .../DATA-DOG/go-sqlmock/expectations_go18.go    |   66 -
 .../go-sqlmock/expectations_go18_test.go        |   64 -
 .../DATA-DOG/go-sqlmock/expectations_test.go    |  154 --
 .../gopkg.in/DATA-DOG/go-sqlmock/result.go      |   39 -
 .../gopkg.in/DATA-DOG/go-sqlmock/result_test.go |   62 -
 .../vendor/gopkg.in/DATA-DOG/go-sqlmock/rows.go |  144 --
 .../gopkg.in/DATA-DOG/go-sqlmock/rows_go18.go   |   20 -
 .../DATA-DOG/go-sqlmock/rows_go18_test.go       |   92 -
 .../gopkg.in/DATA-DOG/go-sqlmock/rows_test.go   |  265 ---
 .../gopkg.in/DATA-DOG/go-sqlmock/sqlmock.go     |  525 -----
 .../DATA-DOG/go-sqlmock/sqlmock_go18.go         |  101 -
 .../DATA-DOG/go-sqlmock/sqlmock_go18_test.go    |  426 ----
 .../DATA-DOG/go-sqlmock/sqlmock_test.go         |  998 ----------
 .../gopkg.in/DATA-DOG/go-sqlmock/statement.go   |   27 -
 .../DATA-DOG/go-sqlmock/statement_test.go       |   33 -
 .../gopkg.in/DATA-DOG/go-sqlmock/stubs_test.go  |   76 -
 .../vendor/gopkg.in/DATA-DOG/go-sqlmock/util.go |   13 -
 .../gopkg.in/DATA-DOG/go-sqlmock/util_test.go   |   21 -
 113 files changed, 17115 insertions(+), 4556 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.sh
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.sh b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.sh
new file mode 100755
index 0000000..ebf4470
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+set -eu
+
+client_configure() {
+	sudo chmod 600 $PQSSLCERTTEST_PATH/postgresql.key
+}
+
+pgdg_repository() {
+	local sourcelist='sources.list.d/postgresql.list'
+
+	curl -sS 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' | sudo apt-key add -
+	echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION | sudo tee "/etc/apt/$sourcelist"
+	sudo apt-get -o Dir::Etc::sourcelist="$sourcelist" -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0' update
+}
+
+postgresql_configure() {
+	sudo tee /etc/postgresql/$PGVERSION/main/pg_hba.conf > /dev/null <<-config
+		local     all         all                               trust
+		hostnossl all         pqgossltest 127.0.0.1/32          reject
+		hostnossl all         pqgosslcert 127.0.0.1/32          reject
+		hostssl   all         pqgossltest 127.0.0.1/32          trust
+		hostssl   all         pqgosslcert 127.0.0.1/32          cert
+		host      all         all         127.0.0.1/32          trust
+		hostnossl all         pqgossltest ::1/128               reject
+		hostnossl all         pqgosslcert ::1/128               reject
+		hostssl   all         pqgossltest ::1/128               trust
+		hostssl   all         pqgosslcert ::1/128               cert
+		host      all         all         ::1/128               trust
+	config
+
+	xargs sudo install -o postgres -g postgres -m 600 -t /var/lib/postgresql/$PGVERSION/main/ <<-certificates
+		certs/root.crt
+		certs/server.crt
+		certs/server.key
+	certificates
+
+	sort -VCu <<-versions ||
+		$PGVERSION
+		9.2
+	versions
+	sudo tee -a /etc/postgresql/$PGVERSION/main/postgresql.conf > /dev/null <<-config
+		ssl_ca_file   = 'root.crt'
+		ssl_cert_file = 'server.crt'
+		ssl_key_file  = 'server.key'
+	config
+
+	echo 127.0.0.1 postgres | sudo tee -a /etc/hosts > /dev/null
+
+	sudo service postgresql restart
+}
+
+postgresql_install() {
+	xargs sudo apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew' install <<-packages
+		postgresql-$PGVERSION
+		postgresql-server-dev-$PGVERSION
+		postgresql-contrib-$PGVERSION
+	packages
+}
+
+postgresql_uninstall() {
+	sudo service postgresql stop
+	xargs sudo apt-get -y --purge remove <<-packages
+		libpq-dev
+		libpq5
+		postgresql
+		postgresql-client-common
+		postgresql-common
+	packages
+	sudo rm -rf /var/lib/postgresql
+}
+
+$1

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.yml
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.yml b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.yml
new file mode 100644
index 0000000..1a4656c
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/.travis.yml
@@ -0,0 +1,45 @@
+language: go
+
+go:
+  - 1.5.x
+  - 1.6.x
+  - 1.7.x
+  - 1.8.x
+  - master
+
+sudo: true
+
+env:
+  global:
+    - PGUSER=postgres
+    - PQGOSSLTESTS=1
+    - PQSSLCERTTEST_PATH=$PWD/certs
+    - PGHOST=127.0.0.1
+  matrix:
+    - PGVERSION=9.6
+    - PGVERSION=9.5
+    - PGVERSION=9.4
+    - PGVERSION=9.3
+    - PGVERSION=9.2
+    - PGVERSION=9.1
+    - PGVERSION=9.0
+
+before_install:
+  - ./.travis.sh postgresql_uninstall
+  - ./.travis.sh pgdg_repository
+  - ./.travis.sh postgresql_install
+  - ./.travis.sh postgresql_configure
+  - ./.travis.sh client_configure
+  - go get golang.org/x/tools/cmd/goimports
+
+before_script:
+  - createdb pqgotest
+  - createuser -DRS pqgossltest
+  - createuser -DRS pqgosslcert
+
+script:
+  - >
+    goimports -d -e $(find -name '*.go') | awk '{ print } END { exit NR == 0 ? 0 : 1 }'
+  - go vet ./...
+  - PQTEST_BINARY_PARAMETERS=no  go test -race -v ./...
+  - PQTEST_BINARY_PARAMETERS=yes go test -race -v ./...

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/CONTRIBUTING.md b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/CONTRIBUTING.md
new file mode 100644
index 0000000..84c937f
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/CONTRIBUTING.md
@@ -0,0 +1,29 @@
+## Contributing to pq
+
+`pq` has a backlog of pull requests, but contributions are still very
+much welcome. You can help with patch review, submitting bug reports,
+or adding new functionality. There is no formal style guide, but
+please conform to the style of existing code and general Go formatting
+conventions when submitting patches.
+
+### Patch review
+
+Help review existing open pull requests by commenting on the code or
+proposed functionality.
+
+### Bug reports
+
+We appreciate any bug reports, but especially ones with self-contained
+(doesn't depend on code outside of pq), minimal (can't be simplified
+further) test cases. It's especially helpful if you can submit a pull
+request with just the failing test case (you'll probably want to
+pattern it after the tests in
+[conn_test.go](https://github.com/lib/pq/blob/master/conn_test.go).
+
+### New functionality
+
+There are a number of pending patches for new functionality, so
+additional feature patches will take a while to merge. Still, patches
+are generally reviewed based on usefulness and complexity in addition
+to time-in-queue, so if you have a knockout idea, take a shot. Feel
+free to open an issue discussion your proposed patch beforehand.

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/LICENSE.md
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/LICENSE.md b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/LICENSE.md
new file mode 100644
index 0000000..5773904
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/LICENSE.md
@@ -0,0 +1,8 @@
+Copyright (c) 2011-2013, 'pq' Contributors
+Portions Copyright (C) 2011 Blake Mizerany
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/README.md
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/README.md b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/README.md
new file mode 100644
index 0000000..7670fc8
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/README.md
@@ -0,0 +1,105 @@
+# pq - A pure Go postgres driver for Go's database/sql package
+
+[![Build Status](https://travis-ci.org/lib/pq.svg?branch=master)](https://travis-ci.org/lib/pq)
+
+## Install
+
+	go get github.com/lib/pq
+
+## Docs
+
+For detailed documentation and basic usage examples, please see the package
+documentation at <http://godoc.org/github.com/lib/pq>.
+
+## Tests
+
+`go test` is used for testing.  A running PostgreSQL server is
+required, with the ability to log in.  The default database to connect
+to test with is "pqgotest," but it can be overridden using environment
+variables.
+
+Example:
+
+	PGHOST=/run/postgresql go test github.com/lib/pq
+
+Optionally, a benchmark suite can be run as part of the tests:
+
+	PGHOST=/run/postgresql go test -bench .
+
+## Features
+
+* SSL
+* Handles bad connections for `database/sql`
+* Scan `time.Time` correctly (i.e. `timestamp[tz]`, `time[tz]`, `date`)
+* Scan binary blobs correctly (i.e. `bytea`)
+* Package for `hstore` support
+* COPY FROM support
+* pq.ParseURL for converting urls to connection strings for sql.Open.
+* Many libpq compatible environment variables
+* Unix socket support
+* Notifications: `LISTEN`/`NOTIFY`
+* pgpass support
+
+## Future / Things you can help with
+
+* Better COPY FROM / COPY TO (see discussion in #181)
+
+## Thank you (alphabetical)
+
+Some of these contributors are from the original library `bmizerany/pq.go` whose
+code still exists in here.
+
+* Andy Balholm (andybalholm)
+* Ben Berkert (benburkert)
+* Benjamin Heatwole (bheatwole)
+* Bill Mill (llimllib)
+* Bjørn Madsen (aeons)
+* Blake Gentry (bgentry)
+* Brad Fitzpatrick (bradfitz)
+* Charlie Melbye (cmelbye)
+* Chris Bandy (cbandy)
+* Chris Gilling (cgilling)
+* Chris Walsh (cwds)
+* Dan Sosedoff (sosedoff)
+* Daniel Farina (fdr)
+* Eric Chlebek (echlebek)
+* Eric Garrido (minusnine)
+* Eric Urban (hydrogen18)
+* Everyone at The Go Team
+* Evan Shaw (edsrzf)
+* Ewan Chou (coocood)
+* Fazal Majid (fazalmajid)
+* Federico Romero (federomero)
+* Fumin (fumin)
+* Gary Burd (garyburd)
+* Heroku (heroku)
+* James Pozdena (jpoz)
+* Jason McVetta (jmcvetta)
+* Jeremy Jay (pbnjay)
+* Joakim Sernbrant (serbaut)
+* John Gallagher (jgallagher)
+* Jonathan Rudenberg (titanous)
+* Joël Stemmer (jstemmer)
+* Kamil Kisiel (kisielk)
+* Kelly Dunn (kellydunn)
+* Keith Rarick (kr)
+* Kir Shatrov (kirs)
+* Lann Martin (lann)
+* Maciek Sakrejda (uhoh-itsmaciek)
+* Marc Brinkmann (mbr)
+* Marko Tiikkaja (johto)
+* Matt Newberry (MattNewberry)
+* Matt Robenolt (mattrobenolt)
+* Martin Olsen (martinolsen)
+* Mike Lewis (mikelikespie)
+* Nicolas Patry (Narsil)
+* Oliver Tonnhofer (olt)
+* Patrick Hayes (phayes)
+* Paul Hammond (paulhammond)
+* Ryan Smith (ryandotsmith)
+* Samuel Stauffer (samuel)
+* Timothée Peignier (cyberdelia)
+* Travis Cline (tmc)
+* TruongSinh Tran-Nguyen (truongsinh)
+* Yaismel Miranda (ympons)
+* notedit (notedit)

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array.go
new file mode 100644
index 0000000..e4933e2
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array.go
@@ -0,0 +1,756 @@
+package pq
+
+import (
+	"bytes"
+	"database/sql"
+	"database/sql/driver"
+	"encoding/hex"
+	"fmt"
+	"reflect"
+	"strconv"
+	"strings"
+)
+
+var typeByteSlice = reflect.TypeOf([]byte{})
+var typeDriverValuer = reflect.TypeOf((*driver.Valuer)(nil)).Elem()
+var typeSQLScanner = reflect.TypeOf((*sql.Scanner)(nil)).Elem()
+
+// Array returns the optimal driver.Valuer and sql.Scanner for an array or
+// slice of any dimension.
+//
+// For example:
+//  db.Query(`SELECT * FROM t WHERE id = ANY($1)`, pq.Array([]int{235, 401}))
+//
+//  var x []sql.NullInt64
+//  db.QueryRow('SELECT ARRAY[235, 401]').Scan(pq.Array(&x))
+//
+// Scanning multi-dimensional arrays is not supported.  Arrays where the lower
+// bound is not one (such as `[0:0]={1}') are not supported.
+func Array(a interface{}) interface {
+	driver.Valuer
+	sql.Scanner
+} {
+	switch a := a.(type) {
+	case []bool:
+		return (*BoolArray)(&a)
+	case []float64:
+		return (*Float64Array)(&a)
+	case []int64:
+		return (*Int64Array)(&a)
+	case []string:
+		return (*StringArray)(&a)
+
+	case *[]bool:
+		return (*BoolArray)(a)
+	case *[]float64:
+		return (*Float64Array)(a)
+	case *[]int64:
+		return (*Int64Array)(a)
+	case *[]string:
+		return (*StringArray)(a)
+	}
+
+	return GenericArray{a}
+}
+
+// ArrayDelimiter may be optionally implemented by driver.Valuer or sql.Scanner
+// to override the array delimiter used by GenericArray.
+type ArrayDelimiter interface {
+	// ArrayDelimiter returns the delimiter character(s) for this element's type.
+	ArrayDelimiter() string
+}
+
+// BoolArray represents a one-dimensional array of the PostgreSQL boolean type.
+type BoolArray []bool
+
+// Scan implements the sql.Scanner interface.
+func (a *BoolArray) Scan(src interface{}) error {
+	switch src := src.(type) {
+	case []byte:
+		return a.scanBytes(src)
+	case string:
+		return a.scanBytes([]byte(src))
+	case nil:
+		*a = nil
+		return nil
+	}
+
+	return fmt.Errorf("pq: cannot convert %T to BoolArray", src)
+}
+
+func (a *BoolArray) scanBytes(src []byte) error {
+	elems, err := scanLinearArray(src, []byte{','}, "BoolArray")
+	if err != nil {
+		return err
+	}
+	if *a != nil && len(elems) == 0 {
+		*a = (*a)[:0]
+	} else {
+		b := make(BoolArray, len(elems))
+		for i, v := range elems {
+			if len(v) != 1 {
+				return fmt.Errorf("pq: could not parse boolean array index %d: invalid boolean %q", i, v)
+			}
+			switch v[0] {
+			case 't':
+				b[i] = true
+			case 'f':
+				b[i] = false
+			default:
+				return fmt.Errorf("pq: could not parse boolean array index %d: invalid boolean %q", i, v)
+			}
+		}
+		*a = b
+	}
+	return nil
+}
+
+// Value implements the driver.Valuer interface.
+func (a BoolArray) Value() (driver.Value, error) {
+	if a == nil {
+		return nil, nil
+	}
+
+	if n := len(a); n > 0 {
+		// There will be exactly two curly brackets, N bytes of values,
+		// and N-1 bytes of delimiters.
+		b := make([]byte, 1+2*n)
+
+		for i := 0; i < n; i++ {
+			b[2*i] = ','
+			if a[i] {
+				b[1+2*i] = 't'
+			} else {
+				b[1+2*i] = 'f'
+			}
+		}
+
+		b[0] = '{'
+		b[2*n] = '}'
+
+		return string(b), nil
+	}
+
+	return "{}", nil
+}
+
+// ByteaArray represents a one-dimensional array of the PostgreSQL bytea type.
+type ByteaArray [][]byte
+
+// Scan implements the sql.Scanner interface.
+func (a *ByteaArray) Scan(src interface{}) error {
+	switch src := src.(type) {
+	case []byte:
+		return a.scanBytes(src)
+	case string:
+		return a.scanBytes([]byte(src))
+	case nil:
+		*a = nil
+		return nil
+	}
+
+	return fmt.Errorf("pq: cannot convert %T to ByteaArray", src)
+}
+
+func (a *ByteaArray) scanBytes(src []byte) error {
+	elems, err := scanLinearArray(src, []byte{','}, "ByteaArray")
+	if err != nil {
+		return err
+	}
+	if *a != nil && len(elems) == 0 {
+		*a = (*a)[:0]
+	} else {
+		b := make(ByteaArray, len(elems))
+		for i, v := range elems {
+			b[i], err = parseBytea(v)
+			if err != nil {
+				return fmt.Errorf("could not parse bytea array index %d: %s", i, err.Error())
+			}
+		}
+		*a = b
+	}
+	return nil
+}
+
+// Value implements the driver.Valuer interface. It uses the "hex" format which
+// is only supported on PostgreSQL 9.0 or newer.
+func (a ByteaArray) Value() (driver.Value, error) {
+	if a == nil {
+		return nil, nil
+	}
+
+	if n := len(a); n > 0 {
+		// There will be at least two curly brackets, 2*N bytes of quotes,
+		// 3*N bytes of hex formatting, and N-1 bytes of delimiters.
+		size := 1 + 6*n
+		for _, x := range a {
+			size += hex.EncodedLen(len(x))
+		}
+
+		b := make([]byte, size)
+
+		for i, s := 0, b; i < n; i++ {
+			o := copy(s, `,"\\x`)
+			o += hex.Encode(s[o:], a[i])
+			s[o] = '"'
+			s = s[o+1:]
+		}
+
+		b[0] = '{'
+		b[size-1] = '}'
+
+		return string(b), nil
+	}
+
+	return "{}", nil
+}
+
+// Float64Array represents a one-dimensional array of the PostgreSQL double
+// precision type.
+type Float64Array []float64
+
+// Scan implements the sql.Scanner interface.
+func (a *Float64Array) Scan(src interface{}) error {
+	switch src := src.(type) {
+	case []byte:
+		return a.scanBytes(src)
+	case string:
+		return a.scanBytes([]byte(src))
+	case nil:
+		*a = nil
+		return nil
+	}
+
+	return fmt.Errorf("pq: cannot convert %T to Float64Array", src)
+}
+
+func (a *Float64Array) scanBytes(src []byte) error {
+	elems, err := scanLinearArray(src, []byte{','}, "Float64Array")
+	if err != nil {
+		return err
+	}
+	if *a != nil && len(elems) == 0 {
+		*a = (*a)[:0]
+	} else {
+		b := make(Float64Array, len(elems))
+		for i, v := range elems {
+			if b[i], err = strconv.ParseFloat(string(v), 64); err != nil {
+				return fmt.Errorf("pq: parsing array element index %d: %v", i, err)
+			}
+		}
+		*a = b
+	}
+	return nil
+}
+
+// Value implements the driver.Valuer interface.
+func (a Float64Array) Value() (driver.Value, error) {
+	if a == nil {
+		return nil, nil
+	}
+
+	if n := len(a); n > 0 {
+		// There will be at least two curly brackets, N bytes of values,
+		// and N-1 bytes of delimiters.
+		b := make([]byte, 1, 1+2*n)
+		b[0] = '{'
+
+		b = strconv.AppendFloat(b, a[0], 'f', -1, 64)
+		for i := 1; i < n; i++ {
+			b = append(b, ',')
+			b = strconv.AppendFloat(b, a[i], 'f', -1, 64)
+		}
+
+		return string(append(b, '}')), nil
+	}
+
+	return "{}", nil
+}
+
+// GenericArray implements the driver.Valuer and sql.Scanner interfaces for
+// an array or slice of any dimension.
+type GenericArray struct{ A interface{} }
+
+func (GenericArray) evaluateDestination(rt reflect.Type) (reflect.Type, func([]byte, reflect.Value) error, string) {
+	var assign func([]byte, reflect.Value) error
+	var del = ","
+
+	// TODO calculate the assign function for other types
+	// TODO repeat this section on the element type of arrays or slices (multidimensional)
+	{
+		if reflect.PtrTo(rt).Implements(typeSQLScanner) {
+			// dest is always addressable because it is an element of a slice.
+			assign = func(src []byte, dest reflect.Value) (err error) {
+				ss := dest.Addr().Interface().(sql.Scanner)
+				if src == nil {
+					err = ss.Scan(nil)
+				} else {
+					err = ss.Scan(src)
+				}
+				return
+			}
+			goto FoundType
+		}
+
+		assign = func([]byte, reflect.Value) error {
+			return fmt.Errorf("pq: scanning to %s is not implemented; only sql.Scanner", rt)
+		}
+	}
+
+FoundType:
+
+	if ad, ok := reflect.Zero(rt).Interface().(ArrayDelimiter); ok {
+		del = ad.ArrayDelimiter()
+	}
+
+	return rt, assign, del
+}
+
+// Scan implements the sql.Scanner interface.
+func (a GenericArray) Scan(src interface{}) error {
+	dpv := reflect.ValueOf(a.A)
+	switch {
+	case dpv.Kind() != reflect.Ptr:
+		return fmt.Errorf("pq: destination %T is not a pointer to array or slice", a.A)
+	case dpv.IsNil():
+		return fmt.Errorf("pq: destination %T is nil", a.A)
+	}
+
+	dv := dpv.Elem()
+	switch dv.Kind() {
+	case reflect.Slice:
+	case reflect.Array:
+	default:
+		return fmt.Errorf("pq: destination %T is not a pointer to array or slice", a.A)
+	}
+
+	switch src := src.(type) {
+	case []byte:
+		return a.scanBytes(src, dv)
+	case string:
+		return a.scanBytes([]byte(src), dv)
+	case nil:
+		if dv.Kind() == reflect.Slice {
+			dv.Set(reflect.Zero(dv.Type()))
+			return nil
+		}
+	}
+
+	return fmt.Errorf("pq: cannot convert %T to %s", src, dv.Type())
+}
+
+func (a GenericArray) scanBytes(src []byte, dv reflect.Value) error {
+	dtype, assign, del := a.evaluateDestination(dv.Type().Elem())
+	dims, elems, err := parseArray(src, []byte(del))
+	if err != nil {
+		return err
+	}
+
+	// TODO allow multidimensional
+
+	if len(dims) > 1 {
+		return fmt.Errorf("pq: scanning from multidimensional ARRAY%s is not implemented",
+			strings.Replace(fmt.Sprint(dims), " ", "][", -1))
+	}
+
+	// Treat a zero-dimensional array like an array with a single dimension of zero.
+	if len(dims) == 0 {
+		dims = append(dims, 0)
+	}
+
+	for i, rt := 0, dv.Type(); i < len(dims); i, rt = i+1, rt.Elem() {
+		switch rt.Kind() {
+		case reflect.Slice:
+		case reflect.Array:
+			if rt.Len() != dims[i] {
+				return fmt.Errorf("pq: cannot convert ARRAY%s to %s",
+					strings.Replace(fmt.Sprint(dims), " ", "][", -1), dv.Type())
+			}
+		default:
+			// TODO handle multidimensional
+		}
+	}
+
+	values := reflect.MakeSlice(reflect.SliceOf(dtype), len(elems), len(elems))
+	for i, e := range elems {
+		if err := assign(e, values.Index(i)); err != nil {
+			return fmt.Errorf("pq: parsing array element index %d: %v", i, err)
+		}
+	}
+
+	// TODO handle multidimensional
+
+	switch dv.Kind() {
+	case reflect.Slice:
+		dv.Set(values.Slice(0, dims[0]))
+	case reflect.Array:
+		for i := 0; i < dims[0]; i++ {
+			dv.Index(i).Set(values.Index(i))
+		}
+	}
+
+	return nil
+}
+
+// Value implements the driver.Valuer interface.
+func (a GenericArray) Value() (driver.Value, error) {
+	if a.A == nil {
+		return nil, nil
+	}
+
+	rv := reflect.ValueOf(a.A)
+
+	switch rv.Kind() {
+	case reflect.Slice:
+		if rv.IsNil() {
+			return nil, nil
+		}
+	case reflect.Array:
+	default:
+		return nil, fmt.Errorf("pq: Unable to convert %T to array", a.A)
+	}
+
+	if n := rv.Len(); n > 0 {
+		// There will be at least two curly brackets, N bytes of values,
+		// and N-1 bytes of delimiters.
+		b := make([]byte, 0, 1+2*n)
+
+		b, _, err := appendArray(b, rv, n)
+		return string(b), err
+	}
+
+	return "{}", nil
+}
+
+// Int64Array represents a one-dimensional array of the PostgreSQL integer types.
+type Int64Array []int64
+
+// Scan implements the sql.Scanner interface.
+func (a *Int64Array) Scan(src interface{}) error {
+	switch src := src.(type) {
+	case []byte:
+		return a.scanBytes(src)
+	case string:
+		return a.scanBytes([]byte(src))
+	case nil:
+		*a = nil
+		return nil
+	}
+
+	return fmt.Errorf("pq: cannot convert %T to Int64Array", src)
+}
+
+func (a *Int64Array) scanBytes(src []byte) error {
+	elems, err := scanLinearArray(src, []byte{','}, "Int64Array")
+	if err != nil {
+		return err
+	}
+	if *a != nil && len(elems) == 0 {
+		*a = (*a)[:0]
+	} else {
+		b := make(Int64Array, len(elems))
+		for i, v := range elems {
+			if b[i], err = strconv.ParseInt(string(v), 10, 64); err != nil {
+				return fmt.Errorf("pq: parsing array element index %d: %v", i, err)
+			}
+		}
+		*a = b
+	}
+	return nil
+}
+
+// Value implements the driver.Valuer interface.
+func (a Int64Array) Value() (driver.Value, error) {
+	if a == nil {
+		return nil, nil
+	}
+
+	if n := len(a); n > 0 {
+		// There will be at least two curly brackets, N bytes of values,
+		// and N-1 bytes of delimiters.
+		b := make([]byte, 1, 1+2*n)
+		b[0] = '{'
+
+		b = strconv.AppendInt(b, a[0], 10)
+		for i := 1; i < n; i++ {
+			b = append(b, ',')
+			b = strconv.AppendInt(b, a[i], 10)
+		}
+
+		return string(append(b, '}')), nil
+	}
+
+	return "{}", nil
+}
+
+// StringArray represents a one-dimensional array of the PostgreSQL character types.
+type StringArray []string
+
+// Scan implements the sql.Scanner interface.
+func (a *StringArray) Scan(src interface{}) error {
+	switch src := src.(type) {
+	case []byte:
+		return a.scanBytes(src)
+	case string:
+		return a.scanBytes([]byte(src))
+	case nil:
+		*a = nil
+		return nil
+	}
+
+	return fmt.Errorf("pq: cannot convert %T to StringArray", src)
+}
+
+func (a *StringArray) scanBytes(src []byte) error {
+	elems, err := scanLinearArray(src, []byte{','}, "StringArray")
+	if err != nil {
+		return err
+	}
+	if *a != nil && len(elems) == 0 {
+		*a = (*a)[:0]
+	} else {
+		b := make(StringArray, len(elems))
+		for i, v := range elems {
+			if b[i] = string(v); v == nil {
+				return fmt.Errorf("pq: parsing array element index %d: cannot convert nil to string", i)
+			}
+		}
+		*a = b
+	}
+	return nil
+}
+
+// Value implements the driver.Valuer interface.
+func (a StringArray) Value() (driver.Value, error) {
+	if a == nil {
+		return nil, nil
+	}
+
+	if n := len(a); n > 0 {
+		// There will be at least two curly brackets, 2*N bytes of quotes,
+		// and N-1 bytes of delimiters.
+		b := make([]byte, 1, 1+3*n)
+		b[0] = '{'
+
+		b = appendArrayQuotedBytes(b, []byte(a[0]))
+		for i := 1; i < n; i++ {
+			b = append(b, ',')
+			b = appendArrayQuotedBytes(b, []byte(a[i]))
+		}
+
+		return string(append(b, '}')), nil
+	}
+
+	return "{}", nil
+}
+
+// appendArray appends rv to the buffer, returning the extended buffer and
+// the delimiter used between elements.
+//
+// It panics when n <= 0 or rv's Kind is not reflect.Array nor reflect.Slice.
+func appendArray(b []byte, rv reflect.Value, n int) ([]byte, string, error) {
+	var del string
+	var err error
+
+	b = append(b, '{')
+
+	if b, del, err = appendArrayElement(b, rv.Index(0)); err != nil {
+		return b, del, err
+	}
+
+	for i := 1; i < n; i++ {
+		b = append(b, del...)
+		if b, del, err = appendArrayElement(b, rv.Index(i)); err != nil {
+			return b, del, err
+		}
+	}
+
+	return append(b, '}'), del, nil
+}
+
+// appendArrayElement appends rv to the buffer, returning the extended buffer
+// and the delimiter to use before the next element.
+//
+// When rv's Kind is neither reflect.Array nor reflect.Slice, it is converted
+// using driver.DefaultParameterConverter and the resulting []byte or string
+// is double-quoted.
+//
+// See http://www.postgresql.org/docs/current/static/arrays.html#ARRAYS-IO
+func appendArrayElement(b []byte, rv reflect.Value) ([]byte, string, error) {
+	if k := rv.Kind(); k == reflect.Array || k == reflect.Slice {
+		if t := rv.Type(); t != typeByteSlice && !t.Implements(typeDriverValuer) {
+			if n := rv.Len(); n > 0 {
+				return appendArray(b, rv, n)
+			}
+
+			return b, "", nil
+		}
+	}
+
+	var del = ","
+	var err error
+	var iv interface{} = rv.Interface()
+
+	if ad, ok := iv.(ArrayDelimiter); ok {
+		del = ad.ArrayDelimiter()
+	}
+
+	if iv, err = driver.DefaultParameterConverter.ConvertValue(iv); err != nil {
+		return b, del, err
+	}
+
+	switch v := iv.(type) {
+	case nil:
+		return append(b, "NULL"...), del, nil
+	case []byte:
+		return appendArrayQuotedBytes(b, v), del, nil
+	case string:
+		return appendArrayQuotedBytes(b, []byte(v)), del, nil
+	}
+
+	b, err = appendValue(b, iv)
+	return b, del, err
+}
+
+func appendArrayQuotedBytes(b, v []byte) []byte {
+	b = append(b, '"')
+	for {
+		i := bytes.IndexAny(v, `"\`)
+		if i < 0 {
+			b = append(b, v...)
+			break
+		}
+		if i > 0 {
+			b = append(b, v[:i]...)
+		}
+		b = append(b, '\\', v[i])
+		v = v[i+1:]
+	}
+	return append(b, '"')
+}
+
+func appendValue(b []byte, v driver.Value) ([]byte, error) {
+	return append(b, encode(nil, v, 0)...), nil
+}
+
+// parseArray extracts the dimensions and elements of an array represented in
+// text format. Only representations emitted by the backend are supported.
+// Notably, whitespace around brackets and delimiters is significant, and NULL
+// is case-sensitive.
+//
+// See http://www.postgresql.org/docs/current/static/arrays.html#ARRAYS-IO
+func parseArray(src, del []byte) (dims []int, elems [][]byte, err error) {
+	var depth, i int
+
+	if len(src) < 1 || src[0] != '{' {
+		return nil, nil, fmt.Errorf("pq: unable to parse array; expected %q at offset %d", '{', 0)
+	}
+
+Open:
+	for i < len(src) {
+		switch src[i] {
+		case '{':
+			depth++
+			i++
+		case '}':
+			elems = make([][]byte, 0)
+			goto Close
+		default:
+			break Open
+		}
+	}
+	dims = make([]int, i)
+
+Element:
+	for i < len(src) {
+		switch src[i] {
+		case '{':
+			if depth == len(dims) {
+				break Element
+			}
+			depth++
+			dims[depth-1] = 0
+			i++
+		case '"':
+			var elem = []byte{}
+			var escape bool
+			for i++; i < len(src); i++ {
+				if escape {
+					elem = append(elem, src[i])
+					escape = false
+				} else {
+					switch src[i] {
+					default:
+						elem = append(elem, src[i])
+					case '\\':
+						escape = true
+					case '"':
+						elems = append(elems, elem)
+						i++
+						break Element
+					}
+				}
+			}
+		default:
+			for start := i; i < len(src); i++ {
+				if bytes.HasPrefix(src[i:], del) || src[i] == '}' {
+					elem := src[start:i]
+					if len(elem) == 0 {
+						return nil, nil, fmt.Errorf("pq: unable to parse array; unexpected %q at offset %d", src[i], i)
+					}
+					if bytes.Equal(elem, []byte("NULL")) {
+						elem = nil
+					}
+					elems = append(elems, elem)
+					break Element
+				}
+			}
+		}
+	}
+
+	for i < len(src) {
+		if bytes.HasPrefix(src[i:], del) && depth > 0 {
+			dims[depth-1]++
+			i += len(del)
+			goto Element
+		} else if src[i] == '}' && depth > 0 {
+			dims[depth-1]++
+			depth--
+			i++
+		} else {
+			return nil, nil, fmt.Errorf("pq: unable to parse array; unexpected %q at offset %d", src[i], i)
+		}
+	}
+
+Close:
+	for i < len(src) {
+		if src[i] == '}' && depth > 0 {
+			depth--
+			i++
+		} else {
+			return nil, nil, fmt.Errorf("pq: unable to parse array; unexpected %q at offset %d", src[i], i)
+		}
+	}
+	if depth > 0 {
+		err = fmt.Errorf("pq: unable to parse array; expected %q at offset %d", '}', i)
+	}
+	if err == nil {
+		for _, d := range dims {
+			if (len(elems) % d) != 0 {
+				err = fmt.Errorf("pq: multidimensional arrays must have elements with matching dimensions")
+			}
+		}
+	}
+	return
+}
+
+func scanLinearArray(src, del []byte, typ string) (elems [][]byte, err error) {
+	dims, elems, err := parseArray(src, del)
+	if err != nil {
+		return nil, err
+	}
+	if len(dims) > 1 {
+		return nil, fmt.Errorf("pq: cannot convert ARRAY%s to %s", strings.Replace(fmt.Sprint(dims), " ", "][", -1), typ)
+	}
+	return elems, err
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array_test.go
new file mode 100644
index 0000000..10b8431
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/array_test.go
@@ -0,0 +1,1317 @@
+package pq
+
+import (
+	"bytes"
+	"database/sql"
+	"database/sql/driver"
+	"math/rand"
+	"reflect"
+	"strings"
+	"testing"
+)
+
+func TestParseArray(t *testing.T) {
+	for _, tt := range []struct {
+		input string
+		delim string
+		dims  []int
+		elems [][]byte
+	}{
+		{`{}`, `,`, nil, [][]byte{}},
+		{`{NULL}`, `,`, []int{1}, [][]byte{nil}},
+		{`{a}`, `,`, []int{1}, [][]byte{{'a'}}},
+		{`{a,b}`, `,`, []int{2}, [][]byte{{'a'}, {'b'}}},
+		{`{{a,b}}`, `,`, []int{1, 2}, [][]byte{{'a'}, {'b'}}},
+		{`{{a},{b}}`, `,`, []int{2, 1}, [][]byte{{'a'}, {'b'}}},
+		{`{{{a,b},{c,d},{e,f}}}`, `,`, []int{1, 3, 2}, [][]byte{
+			{'a'}, {'b'}, {'c'}, {'d'}, {'e'}, {'f'},
+		}},
+		{`{""}`, `,`, []int{1}, [][]byte{{}}},
+		{`{","}`, `,`, []int{1}, [][]byte{{','}}},
+		{`{",",","}`, `,`, []int{2}, [][]byte{{','}, {','}}},
+		{`{{",",","}}`, `,`, []int{1, 2}, [][]byte{{','}, {','}}},
+		{`{{","},{","}}`, `,`, []int{2, 1}, [][]byte{{','}, {','}}},
+		{`{{{",",","},{",",","},{",",","}}}`, `,`, []int{1, 3, 2}, [][]byte{
+			{','}, {','}, {','}, {','}, {','}, {','},
+		}},
+		{`{"\"}"}`, `,`, []int{1}, [][]byte{{'"', '}'}}},
+		{`{"\"","\""}`, `,`, []int{2}, [][]byte{{'"'}, {'"'}}},
+		{`{{"\"","\""}}`, `,`, []int{1, 2}, [][]byte{{'"'}, {'"'}}},
+		{`{{"\""},{"\""}}`, `,`, []int{2, 1}, [][]byte{{'"'}, {'"'}}},
+		{`{{{"\"","\""},{"\"","\""},{"\"","\""}}}`, `,`, []int{1, 3, 2}, [][]byte{
+			{'"'}, {'"'}, {'"'}, {'"'}, {'"'}, {'"'},
+		}},
+		{`{axyzb}`, `xyz`, []int{2}, [][]byte{{'a'}, {'b'}}},
+	} {
+		dims, elems, err := parseArray([]byte(tt.input), []byte(tt.delim))
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %q", tt.input, err)
+		}
+		if !reflect.DeepEqual(dims, tt.dims) {
+			t.Errorf("Expected %v dimensions for %q, got %v", tt.dims, tt.input, dims)
+		}
+		if !reflect.DeepEqual(elems, tt.elems) {
+			t.Errorf("Expected %v elements for %q, got %v", tt.elems, tt.input, elems)
+		}
+	}
+}
+
+func TestParseArrayError(t *testing.T) {
+	for _, tt := range []struct {
+		input, err string
+	}{
+		{``, "expected '{' at offset 0"},
+		{`x`, "expected '{' at offset 0"},
+		{`}`, "expected '{' at offset 0"},
+		{`{`, "expected '}' at offset 1"},
+		{`{{}`, "expected '}' at offset 3"},
+		{`{}}`, "unexpected '}' at offset 2"},
+		{`{,}`, "unexpected ',' at offset 1"},
+		{`{,x}`, "unexpected ',' at offset 1"},
+		{`{x,}`, "unexpected '}' at offset 3"},
+		{`{x,{`, "unexpected '{' at offset 3"},
+		{`{x},`, "unexpected ',' at offset 3"},
+		{`{x}}`, "unexpected '}' at offset 3"},
+		{`{{x}`, "expected '}' at offset 4"},
+		{`{""x}`, "unexpected 'x' at offset 3"},
+		{`{{a},{b,c}}`, "multidimensional arrays must have elements with matching dimensions"},
+	} {
+		_, _, err := parseArray([]byte(tt.input), []byte{','})
+
+		if err == nil {
+			t.Fatalf("Expected error for %q, got none", tt.input)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
+		}
+	}
+}
+
+func TestArrayScanner(t *testing.T) {
+	var s sql.Scanner
+
+	s = Array(&[]bool{})
+	if _, ok := s.(*BoolArray); !ok {
+		t.Errorf("Expected *BoolArray, got %T", s)
+	}
+
+	s = Array(&[]float64{})
+	if _, ok := s.(*Float64Array); !ok {
+		t.Errorf("Expected *Float64Array, got %T", s)
+	}
+
+	s = Array(&[]int64{})
+	if _, ok := s.(*Int64Array); !ok {
+		t.Errorf("Expected *Int64Array, got %T", s)
+	}
+
+	s = Array(&[]string{})
+	if _, ok := s.(*StringArray); !ok {
+		t.Errorf("Expected *StringArray, got %T", s)
+	}
+
+	for _, tt := range []interface{}{
+		&[]sql.Scanner{},
+		&[][]bool{},
+		&[][]float64{},
+		&[][]int64{},
+		&[][]string{},
+	} {
+		s = Array(tt)
+		if _, ok := s.(GenericArray); !ok {
+			t.Errorf("Expected GenericArray for %T, got %T", tt, s)
+		}
+	}
+}
+
+func TestArrayValuer(t *testing.T) {
+	var v driver.Valuer
+
+	v = Array([]bool{})
+	if _, ok := v.(*BoolArray); !ok {
+		t.Errorf("Expected *BoolArray, got %T", v)
+	}
+
+	v = Array([]float64{})
+	if _, ok := v.(*Float64Array); !ok {
+		t.Errorf("Expected *Float64Array, got %T", v)
+	}
+
+	v = Array([]int64{})
+	if _, ok := v.(*Int64Array); !ok {
+		t.Errorf("Expected *Int64Array, got %T", v)
+	}
+
+	v = Array([]string{})
+	if _, ok := v.(*StringArray); !ok {
+		t.Errorf("Expected *StringArray, got %T", v)
+	}
+
+	for _, tt := range []interface{}{
+		nil,
+		[]driver.Value{},
+		[][]bool{},
+		[][]float64{},
+		[][]int64{},
+		[][]string{},
+	} {
+		v = Array(tt)
+		if _, ok := v.(GenericArray); !ok {
+			t.Errorf("Expected GenericArray for %T, got %T", tt, v)
+		}
+	}
+}
+
+func TestBoolArrayScanUnsupported(t *testing.T) {
+	var arr BoolArray
+	err := arr.Scan(1)
+
+	if err == nil {
+		t.Fatal("Expected error when scanning from int")
+	}
+	if !strings.Contains(err.Error(), "int to BoolArray") {
+		t.Errorf("Expected type to be mentioned when scanning, got %q", err)
+	}
+}
+
+func TestBoolArrayScanEmpty(t *testing.T) {
+	var arr BoolArray
+	err := arr.Scan(`{}`)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr == nil || len(arr) != 0 {
+		t.Errorf("Expected empty, got %#v", arr)
+	}
+}
+
+func TestBoolArrayScanNil(t *testing.T) {
+	arr := BoolArray{true, true, true}
+	err := arr.Scan(nil)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr != nil {
+		t.Errorf("Expected nil, got %+v", arr)
+	}
+}
+
+var BoolArrayStringTests = []struct {
+	str string
+	arr BoolArray
+}{
+	{`{}`, BoolArray{}},
+	{`{t}`, BoolArray{true}},
+	{`{f,t}`, BoolArray{false, true}},
+}
+
+func TestBoolArrayScanBytes(t *testing.T) {
+	for _, tt := range BoolArrayStringTests {
+		bytes := []byte(tt.str)
+		arr := BoolArray{true, true, true}
+		err := arr.Scan(bytes)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", bytes, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, bytes, arr)
+		}
+	}
+}
+
+func BenchmarkBoolArrayScanBytes(b *testing.B) {
+	var a BoolArray
+	var x interface{} = []byte(`{t,f,t,f,t,f,t,f,t,f}`)
+
+	for i := 0; i < b.N; i++ {
+		a = BoolArray{}
+		a.Scan(x)
+	}
+}
+
+func TestBoolArrayScanString(t *testing.T) {
+	for _, tt := range BoolArrayStringTests {
+		arr := BoolArray{true, true, true}
+		err := arr.Scan(tt.str)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", tt.str, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, tt.str, arr)
+		}
+	}
+}
+
+func TestBoolArrayScanError(t *testing.T) {
+	for _, tt := range []struct {
+		input, err string
+	}{
+		{``, "unable to parse array"},
+		{`{`, "unable to parse array"},
+		{`{{t},{f}}`, "cannot convert ARRAY[2][1] to BoolArray"},
+		{`{NULL}`, `could not parse boolean array index 0: invalid boolean ""`},
+		{`{a}`, `could not parse boolean array index 0: invalid boolean "a"`},
+		{`{t,b}`, `could not parse boolean array index 1: invalid boolean "b"`},
+		{`{t,f,cd}`, `could not parse boolean array index 2: invalid boolean "cd"`},
+	} {
+		arr := BoolArray{true, true, true}
+		err := arr.Scan(tt.input)
+
+		if err == nil {
+			t.Fatalf("Expected error for %q, got none", tt.input)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
+		}
+		if !reflect.DeepEqual(arr, BoolArray{true, true, true}) {
+			t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr)
+		}
+	}
+}
+
+func TestBoolArrayValue(t *testing.T) {
+	result, err := BoolArray(nil).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for nil, got %v", err)
+	}
+	if result != nil {
+		t.Errorf("Expected nil, got %q", result)
+	}
+
+	result, err = BoolArray([]bool{}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for empty, got %v", err)
+	}
+	if expected := `{}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected empty, got %q", result)
+	}
+
+	result, err = BoolArray([]bool{false, true, false}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if expected := `{f,t,f}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected %q, got %q", expected, result)
+	}
+}
+
+func BenchmarkBoolArrayValue(b *testing.B) {
+	rand.Seed(1)
+	x := make([]bool, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = rand.Intn(2) == 0
+	}
+	a := BoolArray(x)
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func TestByteaArrayScanUnsupported(t *testing.T) {
+	var arr ByteaArray
+	err := arr.Scan(1)
+
+	if err == nil {
+		t.Fatal("Expected error when scanning from int")
+	}
+	if !strings.Contains(err.Error(), "int to ByteaArray") {
+		t.Errorf("Expected type to be mentioned when scanning, got %q", err)
+	}
+}
+
+func TestByteaArrayScanEmpty(t *testing.T) {
+	var arr ByteaArray
+	err := arr.Scan(`{}`)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr == nil || len(arr) != 0 {
+		t.Errorf("Expected empty, got %#v", arr)
+	}
+}
+
+func TestByteaArrayScanNil(t *testing.T) {
+	arr := ByteaArray{{2}, {6}, {0, 0}}
+	err := arr.Scan(nil)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr != nil {
+		t.Errorf("Expected nil, got %+v", arr)
+	}
+}
+
+var ByteaArrayStringTests = []struct {
+	str string
+	arr ByteaArray
+}{
+	{`{}`, ByteaArray{}},
+	{`{NULL}`, ByteaArray{nil}},
+	{`{"\\xfeff"}`, ByteaArray{{'\xFE', '\xFF'}}},
+	{`{"\\xdead","\\xbeef"}`, ByteaArray{{'\xDE', '\xAD'}, {'\xBE', '\xEF'}}},
+}
+
+func TestByteaArrayScanBytes(t *testing.T) {
+	for _, tt := range ByteaArrayStringTests {
+		bytes := []byte(tt.str)
+		arr := ByteaArray{{2}, {6}, {0, 0}}
+		err := arr.Scan(bytes)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", bytes, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, bytes, arr)
+		}
+	}
+}
+
+func BenchmarkByteaArrayScanBytes(b *testing.B) {
+	var a ByteaArray
+	var x interface{} = []byte(`{"\\xfe","\\xff","\\xdead","\\xbeef","\\xfe","\\xff","\\xdead","\\xbeef","\\xfe","\\xff"}`)
+
+	for i := 0; i < b.N; i++ {
+		a = ByteaArray{}
+		a.Scan(x)
+	}
+}
+
+func TestByteaArrayScanString(t *testing.T) {
+	for _, tt := range ByteaArrayStringTests {
+		arr := ByteaArray{{2}, {6}, {0, 0}}
+		err := arr.Scan(tt.str)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", tt.str, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, tt.str, arr)
+		}
+	}
+}
+
+func TestByteaArrayScanError(t *testing.T) {
+	for _, tt := range []struct {
+		input, err string
+	}{
+		{``, "unable to parse array"},
+		{`{`, "unable to parse array"},
+		{`{{"\\xfeff"},{"\\xbeef"}}`, "cannot convert ARRAY[2][1] to ByteaArray"},
+		{`{"\\abc"}`, "could not parse bytea array index 0: could not parse bytea value"},
+	} {
+		arr := ByteaArray{{2}, {6}, {0, 0}}
+		err := arr.Scan(tt.input)
+
+		if err == nil {
+			t.Fatalf("Expected error for %q, got none", tt.input)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
+		}
+		if !reflect.DeepEqual(arr, ByteaArray{{2}, {6}, {0, 0}}) {
+			t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr)
+		}
+	}
+}
+
+func TestByteaArrayValue(t *testing.T) {
+	result, err := ByteaArray(nil).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for nil, got %v", err)
+	}
+	if result != nil {
+		t.Errorf("Expected nil, got %q", result)
+	}
+
+	result, err = ByteaArray([][]byte{}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for empty, got %v", err)
+	}
+	if expected := `{}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected empty, got %q", result)
+	}
+
+	result, err = ByteaArray([][]byte{{'\xDE', '\xAD', '\xBE', '\xEF'}, {'\xFE', '\xFF'}, {}}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if expected := `{"\\xdeadbeef","\\xfeff","\\x"}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected %q, got %q", expected, result)
+	}
+}
+
+func BenchmarkByteaArrayValue(b *testing.B) {
+	rand.Seed(1)
+	x := make([][]byte, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = make([]byte, len(x))
+		for j := 0; j < len(x); j++ {
+			x[i][j] = byte(rand.Int())
+		}
+	}
+	a := ByteaArray(x)
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func TestFloat64ArrayScanUnsupported(t *testing.T) {
+	var arr Float64Array
+	err := arr.Scan(true)
+
+	if err == nil {
+		t.Fatal("Expected error when scanning from bool")
+	}
+	if !strings.Contains(err.Error(), "bool to Float64Array") {
+		t.Errorf("Expected type to be mentioned when scanning, got %q", err)
+	}
+}
+
+func TestFloat64ArrayScanEmpty(t *testing.T) {
+	var arr Float64Array
+	err := arr.Scan(`{}`)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr == nil || len(arr) != 0 {
+		t.Errorf("Expected empty, got %#v", arr)
+	}
+}
+
+func TestFloat64ArrayScanNil(t *testing.T) {
+	arr := Float64Array{5, 5, 5}
+	err := arr.Scan(nil)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr != nil {
+		t.Errorf("Expected nil, got %+v", arr)
+	}
+}
+
+var Float64ArrayStringTests = []struct {
+	str string
+	arr Float64Array
+}{
+	{`{}`, Float64Array{}},
+	{`{1.2}`, Float64Array{1.2}},
+	{`{3.456,7.89}`, Float64Array{3.456, 7.89}},
+	{`{3,1,2}`, Float64Array{3, 1, 2}},
+}
+
+func TestFloat64ArrayScanBytes(t *testing.T) {
+	for _, tt := range Float64ArrayStringTests {
+		bytes := []byte(tt.str)
+		arr := Float64Array{5, 5, 5}
+		err := arr.Scan(bytes)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", bytes, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, bytes, arr)
+		}
+	}
+}
+
+func BenchmarkFloat64ArrayScanBytes(b *testing.B) {
+	var a Float64Array
+	var x interface{} = []byte(`{1.2,3.4,5.6,7.8,9.01,2.34,5.67,8.90,1.234,5.678}`)
+
+	for i := 0; i < b.N; i++ {
+		a = Float64Array{}
+		a.Scan(x)
+	}
+}
+
+func TestFloat64ArrayScanString(t *testing.T) {
+	for _, tt := range Float64ArrayStringTests {
+		arr := Float64Array{5, 5, 5}
+		err := arr.Scan(tt.str)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", tt.str, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, tt.str, arr)
+		}
+	}
+}
+
+func TestFloat64ArrayScanError(t *testing.T) {
+	for _, tt := range []struct {
+		input, err string
+	}{
+		{``, "unable to parse array"},
+		{`{`, "unable to parse array"},
+		{`{{5.6},{7.8}}`, "cannot convert ARRAY[2][1] to Float64Array"},
+		{`{NULL}`, "parsing array element index 0:"},
+		{`{a}`, "parsing array element index 0:"},
+		{`{5.6,a}`, "parsing array element index 1:"},
+		{`{5.6,7.8,a}`, "parsing array element index 2:"},
+	} {
+		arr := Float64Array{5, 5, 5}
+		err := arr.Scan(tt.input)
+
+		if err == nil {
+			t.Fatalf("Expected error for %q, got none", tt.input)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
+		}
+		if !reflect.DeepEqual(arr, Float64Array{5, 5, 5}) {
+			t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr)
+		}
+	}
+}
+
+func TestFloat64ArrayValue(t *testing.T) {
+	result, err := Float64Array(nil).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for nil, got %v", err)
+	}
+	if result != nil {
+		t.Errorf("Expected nil, got %q", result)
+	}
+
+	result, err = Float64Array([]float64{}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for empty, got %v", err)
+	}
+	if expected := `{}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected empty, got %q", result)
+	}
+
+	result, err = Float64Array([]float64{1.2, 3.4, 5.6}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if expected := `{1.2,3.4,5.6}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected %q, got %q", expected, result)
+	}
+}
+
+func BenchmarkFloat64ArrayValue(b *testing.B) {
+	rand.Seed(1)
+	x := make([]float64, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = rand.NormFloat64()
+	}
+	a := Float64Array(x)
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func TestInt64ArrayScanUnsupported(t *testing.T) {
+	var arr Int64Array
+	err := arr.Scan(true)
+
+	if err == nil {
+		t.Fatal("Expected error when scanning from bool")
+	}
+	if !strings.Contains(err.Error(), "bool to Int64Array") {
+		t.Errorf("Expected type to be mentioned when scanning, got %q", err)
+	}
+}
+
+func TestInt64ArrayScanEmpty(t *testing.T) {
+	var arr Int64Array
+	err := arr.Scan(`{}`)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr == nil || len(arr) != 0 {
+		t.Errorf("Expected empty, got %#v", arr)
+	}
+}
+
+func TestInt64ArrayScanNil(t *testing.T) {
+	arr := Int64Array{5, 5, 5}
+	err := arr.Scan(nil)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr != nil {
+		t.Errorf("Expected nil, got %+v", arr)
+	}
+}
+
+var Int64ArrayStringTests = []struct {
+	str string
+	arr Int64Array
+}{
+	{`{}`, Int64Array{}},
+	{`{12}`, Int64Array{12}},
+	{`{345,678}`, Int64Array{345, 678}},
+}
+
+func TestInt64ArrayScanBytes(t *testing.T) {
+	for _, tt := range Int64ArrayStringTests {
+		bytes := []byte(tt.str)
+		arr := Int64Array{5, 5, 5}
+		err := arr.Scan(bytes)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", bytes, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, bytes, arr)
+		}
+	}
+}
+
+func BenchmarkInt64ArrayScanBytes(b *testing.B) {
+	var a Int64Array
+	var x interface{} = []byte(`{1,2,3,4,5,6,7,8,9,0}`)
+
+	for i := 0; i < b.N; i++ {
+		a = Int64Array{}
+		a.Scan(x)
+	}
+}
+
+func TestInt64ArrayScanString(t *testing.T) {
+	for _, tt := range Int64ArrayStringTests {
+		arr := Int64Array{5, 5, 5}
+		err := arr.Scan(tt.str)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", tt.str, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, tt.str, arr)
+		}
+	}
+}
+
+func TestInt64ArrayScanError(t *testing.T) {
+	for _, tt := range []struct {
+		input, err string
+	}{
+		{``, "unable to parse array"},
+		{`{`, "unable to parse array"},
+		{`{{5},{6}}`, "cannot convert ARRAY[2][1] to Int64Array"},
+		{`{NULL}`, "parsing array element index 0:"},
+		{`{a}`, "parsing array element index 0:"},
+		{`{5,a}`, "parsing array element index 1:"},
+		{`{5,6,a}`, "parsing array element index 2:"},
+	} {
+		arr := Int64Array{5, 5, 5}
+		err := arr.Scan(tt.input)
+
+		if err == nil {
+			t.Fatalf("Expected error for %q, got none", tt.input)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
+		}
+		if !reflect.DeepEqual(arr, Int64Array{5, 5, 5}) {
+			t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr)
+		}
+	}
+}
+
+func TestInt64ArrayValue(t *testing.T) {
+	result, err := Int64Array(nil).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for nil, got %v", err)
+	}
+	if result != nil {
+		t.Errorf("Expected nil, got %q", result)
+	}
+
+	result, err = Int64Array([]int64{}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for empty, got %v", err)
+	}
+	if expected := `{}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected empty, got %q", result)
+	}
+
+	result, err = Int64Array([]int64{1, 2, 3}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if expected := `{1,2,3}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected %q, got %q", expected, result)
+	}
+}
+
+func BenchmarkInt64ArrayValue(b *testing.B) {
+	rand.Seed(1)
+	x := make([]int64, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = rand.Int63()
+	}
+	a := Int64Array(x)
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func TestStringArrayScanUnsupported(t *testing.T) {
+	var arr StringArray
+	err := arr.Scan(true)
+
+	if err == nil {
+		t.Fatal("Expected error when scanning from bool")
+	}
+	if !strings.Contains(err.Error(), "bool to StringArray") {
+		t.Errorf("Expected type to be mentioned when scanning, got %q", err)
+	}
+}
+
+func TestStringArrayScanEmpty(t *testing.T) {
+	var arr StringArray
+	err := arr.Scan(`{}`)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr == nil || len(arr) != 0 {
+		t.Errorf("Expected empty, got %#v", arr)
+	}
+}
+
+func TestStringArrayScanNil(t *testing.T) {
+	arr := StringArray{"x", "x", "x"}
+	err := arr.Scan(nil)
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if arr != nil {
+		t.Errorf("Expected nil, got %+v", arr)
+	}
+}
+
+var StringArrayStringTests = []struct {
+	str string
+	arr StringArray
+}{
+	{`{}`, StringArray{}},
+	{`{t}`, StringArray{"t"}},
+	{`{f,1}`, StringArray{"f", "1"}},
+	{`{"a\\b","c d",","}`, StringArray{"a\\b", "c d", ","}},
+}
+
+func TestStringArrayScanBytes(t *testing.T) {
+	for _, tt := range StringArrayStringTests {
+		bytes := []byte(tt.str)
+		arr := StringArray{"x", "x", "x"}
+		err := arr.Scan(bytes)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", bytes, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, bytes, arr)
+		}
+	}
+}
+
+func BenchmarkStringArrayScanBytes(b *testing.B) {
+	var a StringArray
+	var x interface{} = []byte(`{a,b,c,d,e,f,g,h,i,j}`)
+	var y interface{} = []byte(`{"\a","\b","\c","\d","\e","\f","\g","\h","\i","\j"}`)
+
+	for i := 0; i < b.N; i++ {
+		a = StringArray{}
+		a.Scan(x)
+		a = StringArray{}
+		a.Scan(y)
+	}
+}
+
+func TestStringArrayScanString(t *testing.T) {
+	for _, tt := range StringArrayStringTests {
+		arr := StringArray{"x", "x", "x"}
+		err := arr.Scan(tt.str)
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", tt.str, err)
+		}
+		if !reflect.DeepEqual(arr, tt.arr) {
+			t.Errorf("Expected %+v for %q, got %+v", tt.arr, tt.str, arr)
+		}
+	}
+}
+
+func TestStringArrayScanError(t *testing.T) {
+	for _, tt := range []struct {
+		input, err string
+	}{
+		{``, "unable to parse array"},
+		{`{`, "unable to parse array"},
+		{`{{a},{b}}`, "cannot convert ARRAY[2][1] to StringArray"},
+		{`{NULL}`, "parsing array element index 0: cannot convert nil to string"},
+		{`{a,NULL}`, "parsing array element index 1: cannot convert nil to string"},
+		{`{a,b,NULL}`, "parsing array element index 2: cannot convert nil to string"},
+	} {
+		arr := StringArray{"x", "x", "x"}
+		err := arr.Scan(tt.input)
+
+		if err == nil {
+			t.Fatalf("Expected error for %q, got none", tt.input)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for %q, got %q", tt.err, tt.input, err)
+		}
+		if !reflect.DeepEqual(arr, StringArray{"x", "x", "x"}) {
+			t.Errorf("Expected destination not to change for %q, got %+v", tt.input, arr)
+		}
+	}
+}
+
+func TestStringArrayValue(t *testing.T) {
+	result, err := StringArray(nil).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for nil, got %v", err)
+	}
+	if result != nil {
+		t.Errorf("Expected nil, got %q", result)
+	}
+
+	result, err = StringArray([]string{}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for empty, got %v", err)
+	}
+	if expected := `{}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected empty, got %q", result)
+	}
+
+	result, err = StringArray([]string{`a`, `\b`, `c"`, `d,e`}).Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if expected := `{"a","\\b","c\"","d,e"}`; !reflect.DeepEqual(result, expected) {
+		t.Errorf("Expected %q, got %q", expected, result)
+	}
+}
+
+func BenchmarkStringArrayValue(b *testing.B) {
+	x := make([]string, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = strings.Repeat(`abc"def\ghi`, 5)
+	}
+	a := StringArray(x)
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func TestGenericArrayScanUnsupported(t *testing.T) {
+	var s string
+	var ss []string
+	var nsa [1]sql.NullString
+
+	for _, tt := range []struct {
+		src, dest interface{}
+		err       string
+	}{
+		{nil, nil, "destination <nil> is not a pointer to array or slice"},
+		{nil, true, "destination bool is not a pointer to array or slice"},
+		{nil, &s, "destination *string is not a pointer to array or slice"},
+		{nil, ss, "destination []string is not a pointer to array or slice"},
+		{nil, &nsa, "<nil> to [1]sql.NullString"},
+		{true, &ss, "bool to []string"},
+		{`{{x}}`, &ss, "multidimensional ARRAY[1][1] is not implemented"},
+		{`{{x},{x}}`, &ss, "multidimensional ARRAY[2][1] is not implemented"},
+		{`{x}`, &ss, "scanning to string is not implemented"},
+	} {
+		err := GenericArray{tt.dest}.Scan(tt.src)
+
+		if err == nil {
+			t.Fatalf("Expected error for [%#v %#v]", tt.src, tt.dest)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for [%#v %#v], got %q", tt.err, tt.src, tt.dest, err)
+		}
+	}
+}
+
+func TestGenericArrayScanScannerArrayBytes(t *testing.T) {
+	src, expected, nsa := []byte(`{NULL,abc,"\""}`),
+		[3]sql.NullString{{}, {String: `abc`, Valid: true}, {String: `"`, Valid: true}},
+		[3]sql.NullString{{String: ``, Valid: true}, {}, {}}
+
+	if err := (GenericArray{&nsa}).Scan(src); err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if !reflect.DeepEqual(nsa, expected) {
+		t.Errorf("Expected %v, got %v", expected, nsa)
+	}
+}
+
+func TestGenericArrayScanScannerArrayString(t *testing.T) {
+	src, expected, nsa := `{NULL,"\"",xyz}`,
+		[3]sql.NullString{{}, {String: `"`, Valid: true}, {String: `xyz`, Valid: true}},
+		[3]sql.NullString{{String: ``, Valid: true}, {}, {}}
+
+	if err := (GenericArray{&nsa}).Scan(src); err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if !reflect.DeepEqual(nsa, expected) {
+		t.Errorf("Expected %v, got %v", expected, nsa)
+	}
+}
+
+func TestGenericArrayScanScannerSliceEmpty(t *testing.T) {
+	var nss []sql.NullString
+
+	if err := (GenericArray{&nss}).Scan(`{}`); err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if nss == nil || len(nss) != 0 {
+		t.Errorf("Expected empty, got %#v", nss)
+	}
+}
+
+func TestGenericArrayScanScannerSliceNil(t *testing.T) {
+	nss := []sql.NullString{{String: ``, Valid: true}, {}}
+
+	if err := (GenericArray{&nss}).Scan(nil); err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if nss != nil {
+		t.Errorf("Expected nil, got %+v", nss)
+	}
+}
+
+func TestGenericArrayScanScannerSliceBytes(t *testing.T) {
+	src, expected, nss := []byte(`{NULL,abc,"\""}`),
+		[]sql.NullString{{}, {String: `abc`, Valid: true}, {String: `"`, Valid: true}},
+		[]sql.NullString{{String: ``, Valid: true}, {}, {}, {}, {}}
+
+	if err := (GenericArray{&nss}).Scan(src); err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if !reflect.DeepEqual(nss, expected) {
+		t.Errorf("Expected %v, got %v", expected, nss)
+	}
+}
+
+func BenchmarkGenericArrayScanScannerSliceBytes(b *testing.B) {
+	var a GenericArray
+	var x interface{} = []byte(`{a,b,c,d,e,f,g,h,i,j}`)
+	var y interface{} = []byte(`{"\a","\b","\c","\d","\e","\f","\g","\h","\i","\j"}`)
+
+	for i := 0; i < b.N; i++ {
+		a = GenericArray{new([]sql.NullString)}
+		a.Scan(x)
+		a = GenericArray{new([]sql.NullString)}
+		a.Scan(y)
+	}
+}
+
+func TestGenericArrayScanScannerSliceString(t *testing.T) {
+	src, expected, nss := `{NULL,"\"",xyz}`,
+		[]sql.NullString{{}, {String: `"`, Valid: true}, {String: `xyz`, Valid: true}},
+		[]sql.NullString{{String: ``, Valid: true}, {}, {}}
+
+	if err := (GenericArray{&nss}).Scan(src); err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if !reflect.DeepEqual(nss, expected) {
+		t.Errorf("Expected %v, got %v", expected, nss)
+	}
+}
+
+type TildeNullInt64 struct{ sql.NullInt64 }
+
+func (TildeNullInt64) ArrayDelimiter() string { return "~" }
+
+func TestGenericArrayScanDelimiter(t *testing.T) {
+	src, expected, tnis := `{12~NULL~76}`,
+		[]TildeNullInt64{{sql.NullInt64{Int64: 12, Valid: true}}, {}, {sql.NullInt64{Int64: 76, Valid: true}}},
+		[]TildeNullInt64{{sql.NullInt64{Int64: 0, Valid: true}}, {}}
+
+	if err := (GenericArray{&tnis}).Scan(src); err != nil {
+		t.Fatalf("Expected no error for %#v, got %v", src, err)
+	}
+	if !reflect.DeepEqual(tnis, expected) {
+		t.Errorf("Expected %v for %#v, got %v", expected, src, tnis)
+	}
+}
+
+func TestGenericArrayScanErrors(t *testing.T) {
+	var sa [1]string
+	var nis []sql.NullInt64
+	var pss *[]string
+
+	for _, tt := range []struct {
+		src, dest interface{}
+		err       string
+	}{
+		{nil, pss, "destination *[]string is nil"},
+		{`{`, &sa, "unable to parse"},
+		{`{}`, &sa, "cannot convert ARRAY[0] to [1]string"},
+		{`{x,x}`, &sa, "cannot convert ARRAY[2] to [1]string"},
+		{`{x}`, &nis, `parsing array element index 0: converting`},
+	} {
+		err := GenericArray{tt.dest}.Scan(tt.src)
+
+		if err == nil {
+			t.Fatalf("Expected error for [%#v %#v]", tt.src, tt.dest)
+		}
+		if !strings.Contains(err.Error(), tt.err) {
+			t.Errorf("Expected error to contain %q for [%#v %#v], got %q", tt.err, tt.src, tt.dest, err)
+		}
+	}
+}
+
+func TestGenericArrayValueUnsupported(t *testing.T) {
+	_, err := GenericArray{true}.Value()
+
+	if err == nil {
+		t.Fatal("Expected error for bool")
+	}
+	if !strings.Contains(err.Error(), "bool to array") {
+		t.Errorf("Expected type to be mentioned, got %q", err)
+	}
+}
+
+type ByteArrayValuer [1]byte
+type ByteSliceValuer []byte
+type FuncArrayValuer struct {
+	delimiter func() string
+	value     func() (driver.Value, error)
+}
+
+func (a ByteArrayValuer) Value() (driver.Value, error) { return a[:], nil }
+func (b ByteSliceValuer) Value() (driver.Value, error) { return []byte(b), nil }
+func (f FuncArrayValuer) ArrayDelimiter() string       { return f.delimiter() }
+func (f FuncArrayValuer) Value() (driver.Value, error) { return f.value() }
+
+func TestGenericArrayValue(t *testing.T) {
+	result, err := GenericArray{nil}.Value()
+
+	if err != nil {
+		t.Fatalf("Expected no error for nil, got %v", err)
+	}
+	if result != nil {
+		t.Errorf("Expected nil, got %q", result)
+	}
+
+	for _, tt := range []interface{}{
+		[]bool(nil),
+		[][]int(nil),
+		[]*int(nil),
+		[]sql.NullString(nil),
+	} {
+		result, err := GenericArray{tt}.Value()
+
+		if err != nil {
+			t.Fatalf("Expected no error for %#v, got %v", tt, err)
+		}
+		if result != nil {
+			t.Errorf("Expected nil for %#v, got %q", tt, result)
+		}
+	}
+
+	Tilde := func(v driver.Value) FuncArrayValuer {
+		return FuncArrayValuer{
+			func() string { return "~" },
+			func() (driver.Value, error) { return v, nil }}
+	}
+
+	for _, tt := range []struct {
+		result string
+		input  interface{}
+	}{
+		{`{}`, []bool{}},
+		{`{true}`, []bool{true}},
+		{`{true,false}`, []bool{true, false}},
+		{`{true,false}`, [2]bool{true, false}},
+
+		{`{}`, [][]int{{}}},
+		{`{}`, [][]int{{}, {}}},
+		{`{{1}}`, [][]int{{1}}},
+		{`{{1},{2}}`, [][]int{{1}, {2}}},
+		{`{{1,2},{3,4}}`, [][]int{{1, 2}, {3, 4}}},
+		{`{{1,2},{3,4}}`, [2][2]int{{1, 2}, {3, 4}}},
+
+		{`{"a","\\b","c\"","d,e"}`, []string{`a`, `\b`, `c"`, `d,e`}},
+		{`{"a","\\b","c\"","d,e"}`, [][]byte{{'a'}, {'\\', 'b'}, {'c', '"'}, {'d', ',', 'e'}}},
+
+		{`{NULL}`, []*int{nil}},
+		{`{0,NULL}`, []*int{new(int), nil}},
+
+		{`{NULL}`, []sql.NullString{{}}},
+		{`{"\"",NULL}`, []sql.NullString{{String: `"`, Valid: true}, {}}},
+
+		{`{"a","b"}`, []ByteArrayValuer{{'a'}, {'b'}}},
+		{`{{"a","b"},{"c","d"}}`, [][]ByteArrayValuer{{{'a'}, {'b'}}, {{'c'}, {'d'}}}},
+
+		{`{"e","f"}`, []ByteSliceValuer{{'e'}, {'f'}}},
+		{`{{"e","f"},{"g","h"}}`, [][]ByteSliceValuer{{{'e'}, {'f'}}, {{'g'}, {'h'}}}},
+
+		{`{1~2}`, []FuncArrayValuer{Tilde(int64(1)), Tilde(int64(2))}},
+		{`{{1~2}~{3~4}}`, [][]FuncArrayValuer{{Tilde(int64(1)), Tilde(int64(2))}, {Tilde(int64(3)), Tilde(int64(4))}}},
+	} {
+		result, err := GenericArray{tt.input}.Value()
+
+		if err != nil {
+			t.Fatalf("Expected no error for %q, got %v", tt.input, err)
+		}
+		if !reflect.DeepEqual(result, tt.result) {
+			t.Errorf("Expected %q for %q, got %q", tt.result, tt.input, result)
+		}
+	}
+}
+
+func TestGenericArrayValueErrors(t *testing.T) {
+	var v []interface{}
+
+	v = []interface{}{func() {}}
+	if _, err := (GenericArray{v}).Value(); err == nil {
+		t.Errorf("Expected error for %q, got nil", v)
+	}
+
+	v = []interface{}{nil, func() {}}
+	if _, err := (GenericArray{v}).Value(); err == nil {
+		t.Errorf("Expected error for %q, got nil", v)
+	}
+}
+
+func BenchmarkGenericArrayValueBools(b *testing.B) {
+	rand.Seed(1)
+	x := make([]bool, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = rand.Intn(2) == 0
+	}
+	a := GenericArray{x}
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func BenchmarkGenericArrayValueFloat64s(b *testing.B) {
+	rand.Seed(1)
+	x := make([]float64, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = rand.NormFloat64()
+	}
+	a := GenericArray{x}
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func BenchmarkGenericArrayValueInt64s(b *testing.B) {
+	rand.Seed(1)
+	x := make([]int64, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = rand.Int63()
+	}
+	a := GenericArray{x}
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func BenchmarkGenericArrayValueByteSlices(b *testing.B) {
+	x := make([][]byte, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = bytes.Repeat([]byte(`abc"def\ghi`), 5)
+	}
+	a := GenericArray{x}
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func BenchmarkGenericArrayValueStrings(b *testing.B) {
+	x := make([]string, 10)
+	for i := 0; i < len(x); i++ {
+		x[i] = strings.Repeat(`abc"def\ghi`, 5)
+	}
+	a := GenericArray{x}
+
+	for i := 0; i < b.N; i++ {
+		a.Value()
+	}
+}
+
+func TestArrayScanBackend(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	for _, tt := range []struct {
+		s string
+		d sql.Scanner
+		e interface{}
+	}{
+		{`ARRAY[true, false]`, new(BoolArray), &BoolArray{true, false}},
+		{`ARRAY[E'\\xdead', E'\\xbeef']`, new(ByteaArray), &ByteaArray{{'\xDE', '\xAD'}, {'\xBE', '\xEF'}}},
+		{`ARRAY[1.2, 3.4]`, new(Float64Array), &Float64Array{1.2, 3.4}},
+		{`ARRAY[1, 2, 3]`, new(Int64Array), &Int64Array{1, 2, 3}},
+		{`ARRAY['a', E'\\b', 'c"', 'd,e']`, new(StringArray), &StringArray{`a`, `\b`, `c"`, `d,e`}},
+	} {
+		err := db.QueryRow(`SELECT ` + tt.s).Scan(tt.d)
+		if err != nil {
+			t.Errorf("Expected no error when scanning %s into %T, got %v", tt.s, tt.d, err)
+		}
+		if !reflect.DeepEqual(tt.d, tt.e) {
+			t.Errorf("Expected %v when scanning %s into %T, got %v", tt.e, tt.s, tt.d, tt.d)
+		}
+	}
+}
+
+func TestArrayValueBackend(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	for _, tt := range []struct {
+		s string
+		v driver.Valuer
+	}{
+		{`ARRAY[true, false]`, BoolArray{true, false}},
+		{`ARRAY[E'\\xdead', E'\\xbeef']`, ByteaArray{{'\xDE', '\xAD'}, {'\xBE', '\xEF'}}},
+		{`ARRAY[1.2, 3.4]`, Float64Array{1.2, 3.4}},
+		{`ARRAY[1, 2, 3]`, Int64Array{1, 2, 3}},
+		{`ARRAY['a', E'\\b', 'c"', 'd,e']`, StringArray{`a`, `\b`, `c"`, `d,e`}},
+	} {
+		var x int
+		err := db.QueryRow(`SELECT 1 WHERE `+tt.s+` <> $1`, tt.v).Scan(&x)
+		if err != sql.ErrNoRows {
+			t.Errorf("Expected %v to equal %s, got %v", tt.v, tt.s, err)
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/bench_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/bench_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/bench_test.go
new file mode 100644
index 0000000..e71f41d
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/bench_test.go
@@ -0,0 +1,435 @@
+// +build go1.1
+
+package pq
+
+import (
+	"bufio"
+	"bytes"
+	"database/sql"
+	"database/sql/driver"
+	"io"
+	"math/rand"
+	"net"
+	"runtime"
+	"strconv"
+	"strings"
+	"sync"
+	"testing"
+	"time"
+
+	"github.com/lib/pq/oid"
+)
+
+var (
+	selectStringQuery = "SELECT '" + strings.Repeat("0123456789", 10) + "'"
+	selectSeriesQuery = "SELECT generate_series(1, 100)"
+)
+
+func BenchmarkSelectString(b *testing.B) {
+	var result string
+	benchQuery(b, selectStringQuery, &result)
+}
+
+func BenchmarkSelectSeries(b *testing.B) {
+	var result int
+	benchQuery(b, selectSeriesQuery, &result)
+}
+
+func benchQuery(b *testing.B, query string, result interface{}) {
+	b.StopTimer()
+	db := openTestConn(b)
+	defer db.Close()
+	b.StartTimer()
+
+	for i := 0; i < b.N; i++ {
+		benchQueryLoop(b, db, query, result)
+	}
+}
+
+func benchQueryLoop(b *testing.B, db *sql.DB, query string, result interface{}) {
+	rows, err := db.Query(query)
+	if err != nil {
+		b.Fatal(err)
+	}
+	defer rows.Close()
+	for rows.Next() {
+		err = rows.Scan(result)
+		if err != nil {
+			b.Fatal("failed to scan", err)
+		}
+	}
+}
+
+// reading from circularConn yields content[:prefixLen] once, followed by
+// content[prefixLen:] over and over again. It never returns EOF.
+type circularConn struct {
+	content   string
+	prefixLen int
+	pos       int
+	net.Conn  // for all other net.Conn methods that will never be called
+}
+
+func (r *circularConn) Read(b []byte) (n int, err error) {
+	n = copy(b, r.content[r.pos:])
+	r.pos += n
+	if r.pos >= len(r.content) {
+		r.pos = r.prefixLen
+	}
+	return
+}
+
+func (r *circularConn) Write(b []byte) (n int, err error) { return len(b), nil }
+
+func (r *circularConn) Close() error { return nil }
+
+func fakeConn(content string, prefixLen int) *conn {
+	c := &circularConn{content: content, prefixLen: prefixLen}
+	return &conn{buf: bufio.NewReader(c), c: c}
+}
+
+// This benchmark is meant to be the same as BenchmarkSelectString, but takes
+// out some of the factors this package can't control. The numbers are less noisy,
+// but also the costs of network communication aren't accurately represented.
+func BenchmarkMockSelectString(b *testing.B) {
+	b.StopTimer()
+	// taken from a recorded run of BenchmarkSelectString
+	// See: http://www.postgresql.org/docs/current/static/protocol-message-formats.html
+	const response = "1\x00\x00\x00\x04" +
+		"t\x00\x00\x00\x06\x00\x00" +
+		"T\x00\x00\x00!\x00\x01?column?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xc1\xff\xfe\xff\xff\xff\xff\x00\x00" +
+		"Z\x00\x00\x00\x05I" +
+		"2\x00\x00\x00\x04" +
+		"D\x00\x00\x00n\x00\x01\x00\x00\x00d0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" +
+		"C\x00\x00\x00\rSELECT 1\x00" +
+		"Z\x00\x00\x00\x05I" +
+		"3\x00\x00\x00\x04" +
+		"Z\x00\x00\x00\x05I"
+	c := fakeConn(response, 0)
+	b.StartTimer()
+
+	for i := 0; i < b.N; i++ {
+		benchMockQuery(b, c, selectStringQuery)
+	}
+}
+
+var seriesRowData = func() string {
+	var buf bytes.Buffer
+	for i := 1; i <= 100; i++ {
+		digits := byte(2)
+		if i >= 100 {
+			digits = 3
+		} else if i < 10 {
+			digits = 1
+		}
+		buf.WriteString("D\x00\x00\x00")
+		buf.WriteByte(10 + digits)
+		buf.WriteString("\x00\x01\x00\x00\x00")
+		buf.WriteByte(digits)
+		buf.WriteString(strconv.Itoa(i))
+	}
+	return buf.String()
+}()
+
+func BenchmarkMockSelectSeries(b *testing.B) {
+	b.StopTimer()
+	var response = "1\x00\x00\x00\x04" +
+		"t\x00\x00\x00\x06\x00\x00" +
+		"T\x00\x00\x00!\x00\x01?column?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xc1\xff\xfe\xff\xff\xff\xff\x00\x00" +
+		"Z\x00\x00\x00\x05I" +
+		"2\x00\x00\x00\x04" +
+		seriesRowData +
+		"C\x00\x00\x00\x0fSELECT 100\x00" +
+		"Z\x00\x00\x00\x05I" +
+		"3\x00\x00\x00\x04" +
+		"Z\x00\x00\x00\x05I"
+	c := fakeConn(response, 0)
+	b.StartTimer()
+
+	for i := 0; i < b.N; i++ {
+		benchMockQuery(b, c, selectSeriesQuery)
+	}
+}
+
+func benchMockQuery(b *testing.B, c *conn, query string) {
+	stmt, err := c.Prepare(query)
+	if err != nil {
+		b.Fatal(err)
+	}
+	defer stmt.Close()
+	rows, err := stmt.Query(nil)
+	if err != nil {
+		b.Fatal(err)
+	}
+	defer rows.Close()
+	var dest [1]driver.Value
+	for {
+		if err := rows.Next(dest[:]); err != nil {
+			if err == io.EOF {
+				break
+			}
+			b.Fatal(err)
+		}
+	}
+}
+
+func BenchmarkPreparedSelectString(b *testing.B) {
+	var result string
+	benchPreparedQuery(b, selectStringQuery, &result)
+}
+
+func BenchmarkPreparedSelectSeries(b *testing.B) {
+	var result int
+	benchPreparedQuery(b, selectSeriesQuery, &result)
+}
+
+func benchPreparedQuery(b *testing.B, query string, result interface{}) {
+	b.StopTimer()
+	db := openTestConn(b)
+	defer db.Close()
+	stmt, err := db.Prepare(query)
+	if err != nil {
+		b.Fatal(err)
+	}
+	defer stmt.Close()
+	b.StartTimer()
+
+	for i := 0; i < b.N; i++ {
+		benchPreparedQueryLoop(b, db, stmt, result)
+	}
+}
+
+func benchPreparedQueryLoop(b *testing.B, db *sql.DB, stmt *sql.Stmt, result interface{}) {
+	rows, err := stmt.Query()
+	if err != nil {
+		b.Fatal(err)
+	}
+	if !rows.Next() {
+		rows.Close()
+		b.Fatal("no rows")
+	}
+	defer rows.Close()
+	for rows.Next() {
+		err = rows.Scan(&result)
+		if err != nil {
+			b.Fatal("failed to scan")
+		}
+	}
+}
+
+// See the comment for BenchmarkMockSelectString.
+func BenchmarkMockPreparedSelectString(b *testing.B) {
+	b.StopTimer()
+	const parseResponse = "1\x00\x00\x00\x04" +
+		"t\x00\x00\x00\x06\x00\x00" +
+		"T\x00\x00\x00!\x00\x01?column?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xc1\xff\xfe\xff\xff\xff\xff\x00\x00" +
+		"Z\x00\x00\x00\x05I"
+	const responses = parseResponse +
+		"2\x00\x00\x00\x04" +
+		"D\x00\x00\x00n\x00\x01\x00\x00\x00d0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" +
+		"C\x00\x00\x00\rSELECT 1\x00" +
+		"Z\x00\x00\x00\x05I"
+	c := fakeConn(responses, len(parseResponse))
+
+	stmt, err := c.Prepare(selectStringQuery)
+	if err != nil {
+		b.Fatal(err)
+	}
+	b.StartTimer()
+
+	for i := 0; i < b.N; i++ {
+		benchPreparedMockQuery(b, c, stmt)
+	}
+}
+
+func BenchmarkMockPreparedSelectSeries(b *testing.B) {
+	b.StopTimer()
+	const parseResponse = "1\x00\x00\x00\x04" +
+		"t\x00\x00\x00\x06\x00\x00" +
+		"T\x00\x00\x00!\x00\x01?column?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xc1\xff\xfe\xff\xff\xff\xff\x00\x00" +
+		"Z\x00\x00\x00\x05I"
+	var responses = parseResponse +
+		"2\x00\x00\x00\x04" +
+		seriesRowData +
+		"C\x00\x00\x00\x0fSELECT 100\x00" +
+		"Z\x00\x00\x00\x05I"
+	c := fakeConn(responses, len(parseResponse))
+
+	stmt, err := c.Prepare(selectSeriesQuery)
+	if err != nil {
+		b.Fatal(err)
+	}
+	b.StartTimer()
+
+	for i := 0; i < b.N; i++ {
+		benchPreparedMockQuery(b, c, stmt)
+	}
+}
+
+func benchPreparedMockQuery(b *testing.B, c *conn, stmt driver.Stmt) {
+	rows, err := stmt.Query(nil)
+	if err != nil {
+		b.Fatal(err)
+	}
+	defer rows.Close()
+	var dest [1]driver.Value
+	for {
+		if err := rows.Next(dest[:]); err != nil {
+			if err == io.EOF {
+				break
+			}
+			b.Fatal(err)
+		}
+	}
+}
+
+func BenchmarkEncodeInt64(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		encode(&parameterStatus{}, int64(1234), oid.T_int8)
+	}
+}
+
+func BenchmarkEncodeFloat64(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		encode(&parameterStatus{}, 3.14159, oid.T_float8)
+	}
+}
+
+var testByteString = []byte("abcdefghijklmnopqrstuvwxyz")
+
+func BenchmarkEncodeByteaHex(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		encode(&parameterStatus{serverVersion: 90000}, testByteString, oid.T_bytea)
+	}
+}
+func BenchmarkEncodeByteaEscape(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		encode(&parameterStatus{serverVersion: 84000}, testByteString, oid.T_bytea)
+	}
+}
+
+func BenchmarkEncodeBool(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		encode(&parameterStatus{}, true, oid.T_bool)
+	}
+}
+
+var testTimestamptz = time.Date(2001, time.January, 1, 0, 0, 0, 0, time.Local)
+
+func BenchmarkEncodeTimestamptz(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		encode(&parameterStatus{}, testTimestamptz, oid.T_timestamptz)
+	}
+}
+
+var testIntBytes = []byte("1234")
+
+func BenchmarkDecodeInt64(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		decode(&parameterStatus{}, testIntBytes, oid.T_int8, formatText)
+	}
+}
+
+var testFloatBytes = []byte("3.14159")
+
+func BenchmarkDecodeFloat64(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		decode(&parameterStatus{}, testFloatBytes, oid.T_float8, formatText)
+	}
+}
+
+var testBoolBytes = []byte{'t'}
+
+func BenchmarkDecodeBool(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		decode(&parameterStatus{}, testBoolBytes, oid.T_bool, formatText)
+	}
+}
+
+func TestDecodeBool(t *testing.T) {
+	db := openTestConn(t)
+	rows, err := db.Query("select true")
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows.Close()
+}
+
+var testTimestamptzBytes = []byte("2013-09-17 22:15:32.360754-07")
+
+func BenchmarkDecodeTimestamptz(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		decode(&parameterStatus{}, testTimestamptzBytes, oid.T_timestamptz, formatText)
+	}
+}
+
+func BenchmarkDecodeTimestamptzMultiThread(b *testing.B) {
+	oldProcs := runtime.GOMAXPROCS(0)
+	defer runtime.GOMAXPROCS(oldProcs)
+	runtime.GOMAXPROCS(runtime.NumCPU())
+	globalLocationCache = newLocationCache()
+
+	f := func(wg *sync.WaitGroup, loops int) {
+		defer wg.Done()
+		for i := 0; i < loops; i++ {
+			decode(&parameterStatus{}, testTimestamptzBytes, oid.T_timestamptz, formatText)
+		}
+	}
+
+	wg := &sync.WaitGroup{}
+	b.ResetTimer()
+	for j := 0; j < 10; j++ {
+		wg.Add(1)
+		go f(wg, b.N/10)
+	}
+	wg.Wait()
+}
+
+func BenchmarkLocationCache(b *testing.B) {
+	globalLocationCache = newLocationCache()
+	for i := 0; i < b.N; i++ {
+		globalLocationCache.getLocation(rand.Intn(10000))
+	}
+}
+
+func BenchmarkLocationCacheMultiThread(b *testing.B) {
+	oldProcs := runtime.GOMAXPROCS(0)
+	defer runtime.GOMAXPROCS(oldProcs)
+	runtime.GOMAXPROCS(runtime.NumCPU())
+	globalLocationCache = newLocationCache()
+
+	f := func(wg *sync.WaitGroup, loops int) {
+		defer wg.Done()
+		for i := 0; i < loops; i++ {
+			globalLocationCache.getLocation(rand.Intn(10000))
+		}
+	}
+
+	wg := &sync.WaitGroup{}
+	b.ResetTimer()
+	for j := 0; j < 10; j++ {
+		wg.Add(1)
+		go f(wg, b.N/10)
+	}
+	wg.Wait()
+}
+
+// Stress test the performance of parsing results from the wire.
+func BenchmarkResultParsing(b *testing.B) {
+	b.StopTimer()
+
+	db := openTestConn(b)
+	defer db.Close()
+	_, err := db.Exec("BEGIN")
+	if err != nil {
+		b.Fatal(err)
+	}
+
+	b.StartTimer()
+	for i := 0; i < b.N; i++ {
+		res, err := db.Query("SELECT generate_series(1, 50000)")
+		if err != nil {
+			b.Fatal(err)
+		}
+		res.Close()
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/buf.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/buf.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/buf.go
new file mode 100644
index 0000000..666b001
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/buf.go
@@ -0,0 +1,91 @@
+package pq
+
+import (
+	"bytes"
+	"encoding/binary"
+
+	"github.com/lib/pq/oid"
+)
+
+type readBuf []byte
+
+func (b *readBuf) int32() (n int) {
+	n = int(int32(binary.BigEndian.Uint32(*b)))
+	*b = (*b)[4:]
+	return
+}
+
+func (b *readBuf) oid() (n oid.Oid) {
+	n = oid.Oid(binary.BigEndian.Uint32(*b))
+	*b = (*b)[4:]
+	return
+}
+
+// N.B: this is actually an unsigned 16-bit integer, unlike int32
+func (b *readBuf) int16() (n int) {
+	n = int(binary.BigEndian.Uint16(*b))
+	*b = (*b)[2:]
+	return
+}
+
+func (b *readBuf) string() string {
+	i := bytes.IndexByte(*b, 0)
+	if i < 0 {
+		errorf("invalid message format; expected string terminator")
+	}
+	s := (*b)[:i]
+	*b = (*b)[i+1:]
+	return string(s)
+}
+
+func (b *readBuf) next(n int) (v []byte) {
+	v = (*b)[:n]
+	*b = (*b)[n:]
+	return
+}
+
+func (b *readBuf) byte() byte {
+	return b.next(1)[0]
+}
+
+type writeBuf struct {
+	buf []byte
+	pos int
+}
+
+func (b *writeBuf) int32(n int) {
+	x := make([]byte, 4)
+	binary.BigEndian.PutUint32(x, uint32(n))
+	b.buf = append(b.buf, x...)
+}
+
+func (b *writeBuf) int16(n int) {
+	x := make([]byte, 2)
+	binary.BigEndian.PutUint16(x, uint16(n))
+	b.buf = append(b.buf, x...)
+}
+
+func (b *writeBuf) string(s string) {
+	b.buf = append(b.buf, (s + "\000")...)
+}
+
+func (b *writeBuf) byte(c byte) {
+	b.buf = append(b.buf, c)
+}
+
+func (b *writeBuf) bytes(v []byte) {
+	b.buf = append(b.buf, v...)
+}
+
+func (b *writeBuf) wrap() []byte {
+	p := b.buf[b.pos:]
+	binary.BigEndian.PutUint32(p, uint32(len(p)))
+	return b.buf
+}
+
+func (b *writeBuf) next(c byte) {
+	p := b.buf[b.pos:]
+	binary.BigEndian.PutUint32(p, uint32(len(p)))
+	b.pos = len(b.buf) + 1
+	b.buf = append(b.buf, c, 0, 0, 0, 0)
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/README
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/README b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/README
new file mode 100644
index 0000000..24ab7b2
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/README
@@ -0,0 +1,3 @@
+This directory contains certificates and private keys for testing some
+SSL-related functionality in Travis.  Do NOT use these certificates for
+anything other than testing.

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/bogus_root.crt
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/bogus_root.crt b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/bogus_root.crt
new file mode 100644
index 0000000..1239db3
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/bogus_root.crt
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDBjCCAe6gAwIBAgIQSnDYp/Naet9HOZljF5PuwDANBgkqhkiG9w0BAQsFADAr
+MRIwEAYDVQQKEwlDb2Nrcm9hY2gxFTATBgNVBAMTDENvY2tyb2FjaCBDQTAeFw0x
+NjAyMDcxNjQ0MzdaFw0xNzAyMDYxNjQ0MzdaMCsxEjAQBgNVBAoTCUNvY2tyb2Fj
+aDEVMBMGA1UEAxMMQ29ja3JvYWNoIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
+MIIBCgKCAQEAxdln3/UdgP7ayA/G1kT7upjLe4ERwQjYQ25q0e1+vgsB5jhiirxJ
+e0+WkhhYu/mwoSAXzvlsbZ2PWFyfdanZeD/Lh6SvIeWXVVaPcWVWL1TEcoN2jr5+
+E85MMHmbbmaT2he8s6br2tM/UZxyTQ2XRprIzApbDssyw1c0Yufcpu3C6267FLEl
+IfcWrzDhnluFhthhtGXv3ToD8IuMScMC5qlKBXtKmD1B5x14ngO/ecNJ+OlEi0HU
+mavK4KWgI2rDXRZ2EnCpyTZdkc3kkRnzKcg653oOjMDRZdrhfIrha+Jq38ACsUmZ
+Su7Sp5jkIHOCO8Zg+l6GKVSq37dKMapD8wIDAQABoyYwJDAOBgNVHQ8BAf8EBAMC
+AuQwEgYDVR0TAQH/BAgwBgEB/wIBATANBgkqhkiG9w0BAQsFAAOCAQEAwZ2Tu0Yu
+rrSVdMdoPEjT1IZd+5OhM/SLzL0ddtvTithRweLHsw2lDQYlXFqr24i3UGZJQ1sp
+cqSrNwswgLUQT3vWyTjmM51HEb2vMYWKmjZ+sBQYAUP1CadrN/+OTfNGnlF1+B4w
+IXOzh7EvQmJJnNybLe4a/aRvj1NE2n8Z898B76SVU9WbfKKz8VwLzuIPDqkKcZda
+lMy5yzthyztV9YjcWs2zVOUGZvGdAhDrvZuUq6mSmxrBEvR2LBOggmVf3tGRT+Ls
+lW7c9Lrva5zLHuqmoPP07A+vuI9a0D1X44jwGDuPWJ5RnTOQ63Uez12mKNjqleHw
+DnkwNanuO8dhAA==
+-----END CERTIFICATE-----



[3/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations.go
new file mode 100644
index 0000000..415759e
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations.go
@@ -0,0 +1,344 @@
+package sqlmock
+
+import (
+	"database/sql/driver"
+	"fmt"
+	"regexp"
+	"strings"
+	"sync"
+	"time"
+)
+
+// an expectation interface
+type expectation interface {
+	fulfilled() bool
+	Lock()
+	Unlock()
+	String() string
+}
+
+// common expectation struct
+// satisfies the expectation interface
+type commonExpectation struct {
+	sync.Mutex
+	triggered bool
+	err       error
+}
+
+func (e *commonExpectation) fulfilled() bool {
+	return e.triggered
+}
+
+// ExpectedClose is used to manage *sql.DB.Close expectation
+// returned by *Sqlmock.ExpectClose.
+type ExpectedClose struct {
+	commonExpectation
+}
+
+// WillReturnError allows to set an error for *sql.DB.Close action
+func (e *ExpectedClose) WillReturnError(err error) *ExpectedClose {
+	e.err = err
+	return e
+}
+
+// String returns string representation
+func (e *ExpectedClose) String() string {
+	msg := "ExpectedClose => expecting database Close"
+	if e.err != nil {
+		msg += fmt.Sprintf(", which should return error: %s", e.err)
+	}
+	return msg
+}
+
+// ExpectedBegin is used to manage *sql.DB.Begin expectation
+// returned by *Sqlmock.ExpectBegin.
+type ExpectedBegin struct {
+	commonExpectation
+	delay time.Duration
+}
+
+// WillReturnError allows to set an error for *sql.DB.Begin action
+func (e *ExpectedBegin) WillReturnError(err error) *ExpectedBegin {
+	e.err = err
+	return e
+}
+
+// String returns string representation
+func (e *ExpectedBegin) String() string {
+	msg := "ExpectedBegin => expecting database transaction Begin"
+	if e.err != nil {
+		msg += fmt.Sprintf(", which should return error: %s", e.err)
+	}
+	return msg
+}
+
+// WillDelayFor allows to specify duration for which it will delay
+// result. May be used together with Context
+func (e *ExpectedBegin) WillDelayFor(duration time.Duration) *ExpectedBegin {
+	e.delay = duration
+	return e
+}
+
+// ExpectedCommit is used to manage *sql.Tx.Commit expectation
+// returned by *Sqlmock.ExpectCommit.
+type ExpectedCommit struct {
+	commonExpectation
+}
+
+// WillReturnError allows to set an error for *sql.Tx.Close action
+func (e *ExpectedCommit) WillReturnError(err error) *ExpectedCommit {
+	e.err = err
+	return e
+}
+
+// String returns string representation
+func (e *ExpectedCommit) String() string {
+	msg := "ExpectedCommit => expecting transaction Commit"
+	if e.err != nil {
+		msg += fmt.Sprintf(", which should return error: %s", e.err)
+	}
+	return msg
+}
+
+// ExpectedRollback is used to manage *sql.Tx.Rollback expectation
+// returned by *Sqlmock.ExpectRollback.
+type ExpectedRollback struct {
+	commonExpectation
+}
+
+// WillReturnError allows to set an error for *sql.Tx.Rollback action
+func (e *ExpectedRollback) WillReturnError(err error) *ExpectedRollback {
+	e.err = err
+	return e
+}
+
+// String returns string representation
+func (e *ExpectedRollback) String() string {
+	msg := "ExpectedRollback => expecting transaction Rollback"
+	if e.err != nil {
+		msg += fmt.Sprintf(", which should return error: %s", e.err)
+	}
+	return msg
+}
+
+// ExpectedQuery is used to manage *sql.DB.Query, *dql.DB.QueryRow, *sql.Tx.Query,
+// *sql.Tx.QueryRow, *sql.Stmt.Query or *sql.Stmt.QueryRow expectations.
+// Returned by *Sqlmock.ExpectQuery.
+type ExpectedQuery struct {
+	queryBasedExpectation
+	rows  driver.Rows
+	delay time.Duration
+}
+
+// WithArgs will match given expected args to actual database query arguments.
+// if at least one argument does not match, it will return an error. For specific
+// arguments an sqlmock.Argument interface can be used to match an argument.
+func (e *ExpectedQuery) WithArgs(args ...driver.Value) *ExpectedQuery {
+	e.args = args
+	return e
+}
+
+// WillReturnError allows to set an error for expected database query
+func (e *ExpectedQuery) WillReturnError(err error) *ExpectedQuery {
+	e.err = err
+	return e
+}
+
+// WillDelayFor allows to specify duration for which it will delay
+// result. May be used together with Context
+func (e *ExpectedQuery) WillDelayFor(duration time.Duration) *ExpectedQuery {
+	e.delay = duration
+	return e
+}
+
+// String returns string representation
+func (e *ExpectedQuery) String() string {
+	msg := "ExpectedQuery => expecting Query or QueryRow which:"
+	msg += "\n  - matches sql: '" + e.sqlRegex.String() + "'"
+
+	if len(e.args) == 0 {
+		msg += "\n  - is without arguments"
+	} else {
+		msg += "\n  - is with arguments:\n"
+		for i, arg := range e.args {
+			msg += fmt.Sprintf("    %d - %+v\n", i, arg)
+		}
+		msg = strings.TrimSpace(msg)
+	}
+
+	if e.rows != nil {
+		msg += fmt.Sprintf("\n  - %s", e.rows)
+	}
+
+	if e.err != nil {
+		msg += fmt.Sprintf("\n  - should return error: %s", e.err)
+	}
+
+	return msg
+}
+
+// ExpectedExec is used to manage *sql.DB.Exec, *sql.Tx.Exec or *sql.Stmt.Exec expectations.
+// Returned by *Sqlmock.ExpectExec.
+type ExpectedExec struct {
+	queryBasedExpectation
+	result driver.Result
+	delay  time.Duration
+}
+
+// WithArgs will match given expected args to actual database exec operation arguments.
+// if at least one argument does not match, it will return an error. For specific
+// arguments an sqlmock.Argument interface can be used to match an argument.
+func (e *ExpectedExec) WithArgs(args ...driver.Value) *ExpectedExec {
+	e.args = args
+	return e
+}
+
+// WillReturnError allows to set an error for expected database exec action
+func (e *ExpectedExec) WillReturnError(err error) *ExpectedExec {
+	e.err = err
+	return e
+}
+
+// WillDelayFor allows to specify duration for which it will delay
+// result. May be used together with Context
+func (e *ExpectedExec) WillDelayFor(duration time.Duration) *ExpectedExec {
+	e.delay = duration
+	return e
+}
+
+// String returns string representation
+func (e *ExpectedExec) String() string {
+	msg := "ExpectedExec => expecting Exec which:"
+	msg += "\n  - matches sql: '" + e.sqlRegex.String() + "'"
+
+	if len(e.args) == 0 {
+		msg += "\n  - is without arguments"
+	} else {
+		msg += "\n  - is with arguments:\n"
+		var margs []string
+		for i, arg := range e.args {
+			margs = append(margs, fmt.Sprintf("    %d - %+v", i, arg))
+		}
+		msg += strings.Join(margs, "\n")
+	}
+
+	if e.result != nil {
+		res, _ := e.result.(*result)
+		msg += "\n  - should return Result having:"
+		msg += fmt.Sprintf("\n      LastInsertId: %d", res.insertID)
+		msg += fmt.Sprintf("\n      RowsAffected: %d", res.rowsAffected)
+		if res.err != nil {
+			msg += fmt.Sprintf("\n      Error: %s", res.err)
+		}
+	}
+
+	if e.err != nil {
+		msg += fmt.Sprintf("\n  - should return error: %s", e.err)
+	}
+
+	return msg
+}
+
+// WillReturnResult arranges for an expected Exec() to return a particular
+// result, there is sqlmock.NewResult(lastInsertID int64, affectedRows int64) method
+// to build a corresponding result. Or if actions needs to be tested against errors
+// sqlmock.NewErrorResult(err error) to return a given error.
+func (e *ExpectedExec) WillReturnResult(result driver.Result) *ExpectedExec {
+	e.result = result
+	return e
+}
+
+// ExpectedPrepare is used to manage *sql.DB.Prepare or *sql.Tx.Prepare expectations.
+// Returned by *Sqlmock.ExpectPrepare.
+type ExpectedPrepare struct {
+	commonExpectation
+	mock      *sqlmock
+	sqlRegex  *regexp.Regexp
+	statement driver.Stmt
+	closeErr  error
+	delay     time.Duration
+}
+
+// WillReturnError allows to set an error for the expected *sql.DB.Prepare or *sql.Tx.Prepare action.
+func (e *ExpectedPrepare) WillReturnError(err error) *ExpectedPrepare {
+	e.err = err
+	return e
+}
+
+// WillReturnCloseError allows to set an error for this prapared statement Close action
+func (e *ExpectedPrepare) WillReturnCloseError(err error) *ExpectedPrepare {
+	e.closeErr = err
+	return e
+}
+
+// WillDelayFor allows to specify duration for which it will delay
+// result. May be used together with Context
+func (e *ExpectedPrepare) WillDelayFor(duration time.Duration) *ExpectedPrepare {
+	e.delay = duration
+	return e
+}
+
+// ExpectQuery allows to expect Query() or QueryRow() on this prepared statement.
+// this method is convenient in order to prevent duplicating sql query string matching.
+func (e *ExpectedPrepare) ExpectQuery() *ExpectedQuery {
+	eq := &ExpectedQuery{}
+	eq.sqlRegex = e.sqlRegex
+	e.mock.expected = append(e.mock.expected, eq)
+	return eq
+}
+
+// ExpectExec allows to expect Exec() on this prepared statement.
+// this method is convenient in order to prevent duplicating sql query string matching.
+func (e *ExpectedPrepare) ExpectExec() *ExpectedExec {
+	eq := &ExpectedExec{}
+	eq.sqlRegex = e.sqlRegex
+	e.mock.expected = append(e.mock.expected, eq)
+	return eq
+}
+
+// String returns string representation
+func (e *ExpectedPrepare) String() string {
+	msg := "ExpectedPrepare => expecting Prepare statement which:"
+	msg += "\n  - matches sql: '" + e.sqlRegex.String() + "'"
+
+	if e.err != nil {
+		msg += fmt.Sprintf("\n  - should return error: %s", e.err)
+	}
+
+	if e.closeErr != nil {
+		msg += fmt.Sprintf("\n  - should return error on Close: %s", e.closeErr)
+	}
+
+	return msg
+}
+
+// query based expectation
+// adds a query matching logic
+type queryBasedExpectation struct {
+	commonExpectation
+	sqlRegex *regexp.Regexp
+	args     []driver.Value
+}
+
+func (e *queryBasedExpectation) attemptMatch(sql string, args []namedValue) (err error) {
+	if !e.queryMatches(sql) {
+		return fmt.Errorf(`could not match sql: "%s" with expected regexp "%s"`, sql, e.sqlRegex.String())
+	}
+
+	// catch panic
+	defer func() {
+		if e := recover(); e != nil {
+			_, ok := e.(error)
+			if !ok {
+				err = fmt.Errorf(e.(string))
+			}
+		}
+	}()
+
+	err = e.argsMatches(args)
+	return
+}
+
+func (e *queryBasedExpectation) queryMatches(sql string) bool {
+	return e.sqlRegex.MatchString(sql)
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_before_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_before_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_before_go18.go
new file mode 100644
index 0000000..146f240
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_before_go18.go
@@ -0,0 +1,52 @@
+// +build !go1.8
+
+package sqlmock
+
+import (
+	"database/sql/driver"
+	"fmt"
+	"reflect"
+)
+
+// WillReturnRows specifies the set of resulting rows that will be returned
+// by the triggered query
+func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery {
+	e.rows = &rowSets{sets: []*Rows{rows}}
+	return e
+}
+
+func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
+	if nil == e.args {
+		return nil
+	}
+	if len(args) != len(e.args) {
+		return fmt.Errorf("expected %d, but got %d arguments", len(e.args), len(args))
+	}
+	for k, v := range args {
+		// custom argument matcher
+		matcher, ok := e.args[k].(Argument)
+		if ok {
+			// @TODO: does it make sense to pass value instead of named value?
+			if !matcher.Match(v.Value) {
+				return fmt.Errorf("matcher %T could not match %d argument %T - %+v", matcher, k, args[k], args[k])
+			}
+			continue
+		}
+
+		dval := e.args[k]
+		// convert to driver converter
+		darg, err := driver.DefaultParameterConverter.ConvertValue(dval)
+		if err != nil {
+			return fmt.Errorf("could not convert %d argument %T - %+v to driver value: %s", k, e.args[k], e.args[k], err)
+		}
+
+		if !driver.IsValue(darg) {
+			return fmt.Errorf("argument %d: non-subset type %T returned from Value", k, darg)
+		}
+
+		if !reflect.DeepEqual(darg, v.Value) {
+			return fmt.Errorf("argument %d expected [%T - %+v] does not match actual [%T - %+v]", k, darg, darg, v.Value, v.Value)
+		}
+	}
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18.go
new file mode 100644
index 0000000..2b4b44e
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18.go
@@ -0,0 +1,66 @@
+// +build go1.8
+
+package sqlmock
+
+import (
+	"database/sql"
+	"database/sql/driver"
+	"fmt"
+	"reflect"
+)
+
+// WillReturnRows specifies the set of resulting rows that will be returned
+// by the triggered query
+func (e *ExpectedQuery) WillReturnRows(rows ...*Rows) *ExpectedQuery {
+	sets := make([]*Rows, len(rows))
+	for i, r := range rows {
+		sets[i] = r
+	}
+	e.rows = &rowSets{sets: sets}
+	return e
+}
+
+func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
+	if nil == e.args {
+		return nil
+	}
+	if len(args) != len(e.args) {
+		return fmt.Errorf("expected %d, but got %d arguments", len(e.args), len(args))
+	}
+	// @TODO should we assert either all args are named or ordinal?
+	for k, v := range args {
+		// custom argument matcher
+		matcher, ok := e.args[k].(Argument)
+		if ok {
+			if !matcher.Match(v.Value) {
+				return fmt.Errorf("matcher %T could not match %d argument %T - %+v", matcher, k, args[k], args[k])
+			}
+			continue
+		}
+
+		dval := e.args[k]
+		if named, isNamed := dval.(sql.NamedArg); isNamed {
+			dval = named.Value
+			if v.Name != named.Name {
+				return fmt.Errorf("named argument %d: name: \"%s\" does not match expected: \"%s\"", k, v.Name, named.Name)
+			}
+		} else if k+1 != v.Ordinal {
+			return fmt.Errorf("argument %d: ordinal position: %d does not match expected: %d", k, k+1, v.Ordinal)
+		}
+
+		// convert to driver converter
+		darg, err := driver.DefaultParameterConverter.ConvertValue(dval)
+		if err != nil {
+			return fmt.Errorf("could not convert %d argument %T - %+v to driver value: %s", k, e.args[k], e.args[k], err)
+		}
+
+		if !driver.IsValue(darg) {
+			return fmt.Errorf("argument %d: non-subset type %T returned from Value", k, darg)
+		}
+
+		if !reflect.DeepEqual(darg, v.Value) {
+			return fmt.Errorf("argument %d expected [%T - %+v] does not match actual [%T - %+v]", k, darg, darg, v.Value, v.Value)
+		}
+	}
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18_test.go
new file mode 100644
index 0000000..5f30d2f
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_go18_test.go
@@ -0,0 +1,64 @@
+// +build go1.8
+
+package sqlmock
+
+import (
+	"database/sql"
+	"database/sql/driver"
+	"testing"
+)
+
+func TestQueryExpectationNamedArgComparison(t *testing.T) {
+	e := &queryBasedExpectation{}
+	against := []namedValue{{Value: int64(5), Name: "id"}}
+	if err := e.argsMatches(against); err != nil {
+		t.Errorf("arguments should match, since the no expectation was set, but got err: %s", err)
+	}
+
+	e.args = []driver.Value{
+		sql.Named("id", 5),
+		sql.Named("s", "str"),
+	}
+
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments should not match, since the size is not the same")
+	}
+
+	against = []namedValue{
+		{Value: int64(5), Name: "id"},
+		{Value: "str", Name: "s"},
+	}
+
+	if err := e.argsMatches(against); err != nil {
+		t.Errorf("arguments should have matched, but it did not: %v", err)
+	}
+
+	against = []namedValue{
+		{Value: int64(5), Name: "id"},
+		{Value: "str", Name: "username"},
+	}
+
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments matched, but it should have not due to Name")
+	}
+
+	e.args = []driver.Value{int64(5), "str"}
+
+	against = []namedValue{
+		{Value: int64(5), Ordinal: 0},
+		{Value: "str", Ordinal: 1},
+	}
+
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments matched, but it should have not due to wrong Ordinal position")
+	}
+
+	against = []namedValue{
+		{Value: int64(5), Ordinal: 1},
+		{Value: "str", Ordinal: 2},
+	}
+
+	if err := e.argsMatches(against); err != nil {
+		t.Errorf("arguments should have matched, but it did not: %v", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_test.go
new file mode 100644
index 0000000..2e3c097
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/expectations_test.go
@@ -0,0 +1,154 @@
+package sqlmock
+
+import (
+	"database/sql/driver"
+	"fmt"
+	"regexp"
+	"testing"
+	"time"
+)
+
+func TestQueryExpectationArgComparison(t *testing.T) {
+	e := &queryBasedExpectation{}
+	against := []namedValue{{Value: int64(5), Ordinal: 1}}
+	if err := e.argsMatches(against); err != nil {
+		t.Errorf("arguments should match, since the no expectation was set, but got err: %s", err)
+	}
+
+	e.args = []driver.Value{5, "str"}
+
+	against = []namedValue{{Value: int64(5), Ordinal: 1}}
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments should not match, since the size is not the same")
+	}
+
+	against = []namedValue{
+		{Value: int64(3), Ordinal: 1},
+		{Value: "str", Ordinal: 2},
+	}
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments should not match, since the first argument (int value) is different")
+	}
+
+	against = []namedValue{
+		{Value: int64(5), Ordinal: 1},
+		{Value: "st", Ordinal: 2},
+	}
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments should not match, since the second argument (string value) is different")
+	}
+
+	against = []namedValue{
+		{Value: int64(5), Ordinal: 1},
+		{Value: "str", Ordinal: 2},
+	}
+	if err := e.argsMatches(against); err != nil {
+		t.Errorf("arguments should match, but it did not: %s", err)
+	}
+
+	const longForm = "Jan 2, 2006 at 3:04pm (MST)"
+	tm, _ := time.Parse(longForm, "Feb 3, 2013 at 7:54pm (PST)")
+	e.args = []driver.Value{5, tm}
+
+	against = []namedValue{
+		{Value: int64(5), Ordinal: 1},
+		{Value: tm, Ordinal: 2},
+	}
+	if err := e.argsMatches(against); err != nil {
+		t.Error("arguments should match, but it did not")
+	}
+
+	e.args = []driver.Value{5, AnyArg()}
+	if err := e.argsMatches(against); err != nil {
+		t.Errorf("arguments should match, but it did not: %s", err)
+	}
+}
+
+func TestQueryExpectationArgComparisonBool(t *testing.T) {
+	var e *queryBasedExpectation
+
+	e = &queryBasedExpectation{args: []driver.Value{true}}
+	against := []namedValue{
+		{Value: true, Ordinal: 1},
+	}
+	if err := e.argsMatches(against); err != nil {
+		t.Error("arguments should match, since arguments are the same")
+	}
+
+	e = &queryBasedExpectation{args: []driver.Value{false}}
+	against = []namedValue{
+		{Value: false, Ordinal: 1},
+	}
+	if err := e.argsMatches(against); err != nil {
+		t.Error("arguments should match, since argument are the same")
+	}
+
+	e = &queryBasedExpectation{args: []driver.Value{true}}
+	against = []namedValue{
+		{Value: false, Ordinal: 1},
+	}
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments should not match, since argument is different")
+	}
+
+	e = &queryBasedExpectation{args: []driver.Value{false}}
+	against = []namedValue{
+		{Value: true, Ordinal: 1},
+	}
+	if err := e.argsMatches(against); err == nil {
+		t.Error("arguments should not match, since argument is different")
+	}
+}
+
+func TestQueryExpectationSqlMatch(t *testing.T) {
+	e := &ExpectedExec{}
+
+	e.sqlRegex = regexp.MustCompile("SELECT x FROM")
+	if !e.queryMatches("SELECT x FROM someting") {
+		t.Errorf("Sql must have matched the query")
+	}
+
+	e.sqlRegex = regexp.MustCompile("SELECT COUNT\\(x\\) FROM")
+	if !e.queryMatches("SELECT COUNT(x) FROM someting") {
+		t.Errorf("Sql must have matched the query")
+	}
+}
+
+func ExampleExpectedExec() {
+	db, mock, _ := New()
+	result := NewErrorResult(fmt.Errorf("some error"))
+	mock.ExpectExec("^INSERT (.+)").WillReturnResult(result)
+	res, _ := db.Exec("INSERT something")
+	_, err := res.LastInsertId()
+	fmt.Println(err)
+	// Output: some error
+}
+
+func TestBuildQuery(t *testing.T) {
+	db, mock, _ := New()
+	query := `
+		SELECT
+			name,
+			email,
+			address,
+			anotherfield
+		FROM user
+		where
+			name    = 'John'
+			and
+			address = 'Jakarta'
+
+	`
+
+	mock.ExpectQuery(query)
+	mock.ExpectExec(query)
+	mock.ExpectPrepare(query)
+
+	db.QueryRow(query)
+	db.Exec(query)
+	db.Prepare(query)
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Error(err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result.go
new file mode 100644
index 0000000..a63e72b
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result.go
@@ -0,0 +1,39 @@
+package sqlmock
+
+import (
+	"database/sql/driver"
+)
+
+// Result satisfies sql driver Result, which
+// holds last insert id and rows affected
+// by Exec queries
+type result struct {
+	insertID     int64
+	rowsAffected int64
+	err          error
+}
+
+// NewResult creates a new sql driver Result
+// for Exec based query mocks.
+func NewResult(lastInsertID int64, rowsAffected int64) driver.Result {
+	return &result{
+		insertID:     lastInsertID,
+		rowsAffected: rowsAffected,
+	}
+}
+
+// NewErrorResult creates a new sql driver Result
+// which returns an error given for both interface methods
+func NewErrorResult(err error) driver.Result {
+	return &result{
+		err: err,
+	}
+}
+
+func (r *result) LastInsertId() (int64, error) {
+	return r.insertID, r.err
+}
+
+func (r *result) RowsAffected() (int64, error) {
+	return r.rowsAffected, r.err
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result_test.go
new file mode 100644
index 0000000..08d47c9
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/result_test.go
@@ -0,0 +1,62 @@
+package sqlmock
+
+import (
+	"fmt"
+	"testing"
+)
+
+// used for examples
+var mock = &sqlmock{}
+
+func ExampleNewErrorResult() {
+	db, mock, _ := New()
+	result := NewErrorResult(fmt.Errorf("some error"))
+	mock.ExpectExec("^INSERT (.+)").WillReturnResult(result)
+	res, _ := db.Exec("INSERT something")
+	_, err := res.LastInsertId()
+	fmt.Println(err)
+	// Output: some error
+}
+
+func ExampleNewResult() {
+	var lastInsertID, affected int64
+	result := NewResult(lastInsertID, affected)
+	mock.ExpectExec("^INSERT (.+)").WillReturnResult(result)
+	fmt.Println(mock.ExpectationsWereMet())
+	// Output: there is a remaining expectation which was not matched: ExpectedExec => expecting Exec which:
+	//   - matches sql: '^INSERT (.+)'
+	//   - is without arguments
+	//   - should return Result having:
+	//       LastInsertId: 0
+	//       RowsAffected: 0
+}
+
+func TestShouldReturnValidSqlDriverResult(t *testing.T) {
+	result := NewResult(1, 2)
+	id, err := result.LastInsertId()
+	if 1 != id {
+		t.Errorf("Expected last insert id to be 1, but got: %d", id)
+	}
+	if err != nil {
+		t.Errorf("expected no error, but got: %s", err)
+	}
+	affected, err := result.RowsAffected()
+	if 2 != affected {
+		t.Errorf("Expected affected rows to be 2, but got: %d", affected)
+	}
+	if err != nil {
+		t.Errorf("expected no error, but got: %s", err)
+	}
+}
+
+func TestShouldReturnErroeSqlDriverResult(t *testing.T) {
+	result := NewErrorResult(fmt.Errorf("some error"))
+	_, err := result.LastInsertId()
+	if err == nil {
+		t.Error("expected error, but got none")
+	}
+	_, err = result.RowsAffected()
+	if err == nil {
+		t.Error("expected error, but got none")
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows.go
new file mode 100644
index 0000000..39f9f83
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows.go
@@ -0,0 +1,144 @@
+package sqlmock
+
+import (
+	"database/sql/driver"
+	"encoding/csv"
+	"fmt"
+	"io"
+	"strings"
+)
+
+// CSVColumnParser is a function which converts trimmed csv
+// column string to a []byte representation. currently
+// transforms NULL to nil
+var CSVColumnParser = func(s string) []byte {
+	switch {
+	case strings.ToLower(s) == "null":
+		return nil
+	}
+	return []byte(s)
+}
+
+type rowSets struct {
+	sets []*Rows
+	pos  int
+}
+
+func (rs *rowSets) Columns() []string {
+	return rs.sets[rs.pos].cols
+}
+
+func (rs *rowSets) Close() error {
+	return rs.sets[rs.pos].closeErr
+}
+
+// advances to next row
+func (rs *rowSets) Next(dest []driver.Value) error {
+	r := rs.sets[rs.pos]
+	r.pos++
+	if r.pos > len(r.rows) {
+		return io.EOF // per interface spec
+	}
+
+	for i, col := range r.rows[r.pos-1] {
+		dest[i] = col
+	}
+
+	return r.nextErr[r.pos-1]
+}
+
+// transforms to debuggable printable string
+func (rs *rowSets) String() string {
+	msg := "should return rows:\n"
+	if len(rs.sets) == 1 {
+		for n, row := range rs.sets[0].rows {
+			msg += fmt.Sprintf("    row %d - %+v\n", n, row)
+		}
+		return strings.TrimSpace(msg)
+	}
+	for i, set := range rs.sets {
+		msg += fmt.Sprintf("    result set: %d\n", i)
+		for n, row := range set.rows {
+			msg += fmt.Sprintf("      row %d - %+v\n", n, row)
+		}
+	}
+	return strings.TrimSpace(msg)
+}
+
+// Rows is a mocked collection of rows to
+// return for Query result
+type Rows struct {
+	cols     []string
+	rows     [][]driver.Value
+	pos      int
+	nextErr  map[int]error
+	closeErr error
+}
+
+// NewRows allows Rows to be created from a
+// sql driver.Value slice or from the CSV string and
+// to be used as sql driver.Rows
+func NewRows(columns []string) *Rows {
+	return &Rows{cols: columns, nextErr: make(map[int]error)}
+}
+
+// CloseError allows to set an error
+// which will be returned by rows.Close
+// function.
+//
+// The close error will be triggered only in cases
+// when rows.Next() EOF was not yet reached, that is
+// a default sql library behavior
+func (r *Rows) CloseError(err error) *Rows {
+	r.closeErr = err
+	return r
+}
+
+// RowError allows to set an error
+// which will be returned when a given
+// row number is read
+func (r *Rows) RowError(row int, err error) *Rows {
+	r.nextErr[row] = err
+	return r
+}
+
+// AddRow composed from database driver.Value slice
+// return the same instance to perform subsequent actions.
+// Note that the number of values must match the number
+// of columns
+func (r *Rows) AddRow(values ...driver.Value) *Rows {
+	if len(values) != len(r.cols) {
+		panic("Expected number of values to match number of columns")
+	}
+
+	row := make([]driver.Value, len(r.cols))
+	for i, v := range values {
+		row[i] = v
+	}
+
+	r.rows = append(r.rows, row)
+	return r
+}
+
+// FromCSVString build rows from csv string.
+// return the same instance to perform subsequent actions.
+// Note that the number of values must match the number
+// of columns
+func (r *Rows) FromCSVString(s string) *Rows {
+	res := strings.NewReader(strings.TrimSpace(s))
+	csvReader := csv.NewReader(res)
+
+	for {
+		res, err := csvReader.Read()
+		if err != nil || res == nil {
+			break
+		}
+
+		row := make([]driver.Value, len(r.cols))
+		for i, v := range res {
+			row[i] = CSVColumnParser(strings.TrimSpace(v))
+		}
+		r.rows = append(r.rows, row)
+	}
+	return r
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18.go
new file mode 100644
index 0000000..4ecf84e
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18.go
@@ -0,0 +1,20 @@
+// +build go1.8
+
+package sqlmock
+
+import "io"
+
+// Implement the "RowsNextResultSet" interface
+func (rs *rowSets) HasNextResultSet() bool {
+	return rs.pos+1 < len(rs.sets)
+}
+
+// Implement the "RowsNextResultSet" interface
+func (rs *rowSets) NextResultSet() error {
+	if !rs.HasNextResultSet() {
+		return io.EOF
+	}
+
+	rs.pos++
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18_test.go
new file mode 100644
index 0000000..297e7c0
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_go18_test.go
@@ -0,0 +1,92 @@
+// +build go1.8
+
+package sqlmock
+
+import (
+	"fmt"
+	"testing"
+)
+
+func TestQueryMultiRows(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs1 := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
+	rs2 := NewRows([]string{"name"}).AddRow("gopher").AddRow("john").AddRow("jane").RowError(2, fmt.Errorf("error"))
+
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = \\?;SELECT name FROM users").
+		WithArgs(5).
+		WillReturnRows(rs1, rs2)
+
+	rows, err := db.Query("SELECT id, title FROM articles WHERE id = ?;SELECT name FROM users", 5)
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+	defer rows.Close()
+
+	if !rows.Next() {
+		t.Error("expected a row to be available in first result set")
+	}
+
+	var id int
+	var name string
+
+	err = rows.Scan(&id, &name)
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	if id != 5 || name != "hello world" {
+		t.Errorf("unexpected row values id: %v name: %v", id, name)
+	}
+
+	if rows.Next() {
+		t.Error("was not expecting next row in first result set")
+	}
+
+	if !rows.NextResultSet() {
+		t.Error("had to have next result set")
+	}
+
+	if !rows.Next() {
+		t.Error("expected a row to be available in second result set")
+	}
+
+	err = rows.Scan(&name)
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	if name != "gopher" {
+		t.Errorf("unexpected row name: %v", name)
+	}
+
+	if !rows.Next() {
+		t.Error("expected a row to be available in second result set")
+	}
+
+	err = rows.Scan(&name)
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	if name != "john" {
+		t.Errorf("unexpected row name: %v", name)
+	}
+
+	if rows.Next() {
+		t.Error("expected next row to produce error")
+	}
+
+	if rows.Err() == nil {
+		t.Error("expected an error, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_test.go
new file mode 100644
index 0000000..56e834e
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/rows_test.go
@@ -0,0 +1,265 @@
+package sqlmock
+
+import (
+	"database/sql"
+	"fmt"
+	"testing"
+)
+
+func ExampleRows() {
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("failed to open sqlmock database:", err)
+	}
+	defer db.Close()
+
+	rows := NewRows([]string{"id", "title"}).
+		AddRow(1, "one").
+		AddRow(2, "two")
+
+	mock.ExpectQuery("SELECT").WillReturnRows(rows)
+
+	rs, _ := db.Query("SELECT")
+	defer rs.Close()
+
+	for rs.Next() {
+		var id int
+		var title string
+		rs.Scan(&id, &title)
+		fmt.Println("scanned id:", id, "and title:", title)
+	}
+
+	if rs.Err() != nil {
+		fmt.Println("got rows error:", rs.Err())
+	}
+	// Output: scanned id: 1 and title: one
+	// scanned id: 2 and title: two
+}
+
+func ExampleRows_rowError() {
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("failed to open sqlmock database:", err)
+	}
+	defer db.Close()
+
+	rows := NewRows([]string{"id", "title"}).
+		AddRow(0, "one").
+		AddRow(1, "two").
+		RowError(1, fmt.Errorf("row error"))
+	mock.ExpectQuery("SELECT").WillReturnRows(rows)
+
+	rs, _ := db.Query("SELECT")
+	defer rs.Close()
+
+	for rs.Next() {
+		var id int
+		var title string
+		rs.Scan(&id, &title)
+		fmt.Println("scanned id:", id, "and title:", title)
+	}
+
+	if rs.Err() != nil {
+		fmt.Println("got rows error:", rs.Err())
+	}
+	// Output: scanned id: 0 and title: one
+	// got rows error: row error
+}
+
+func ExampleRows_closeError() {
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("failed to open sqlmock database:", err)
+	}
+	defer db.Close()
+
+	rows := NewRows([]string{"id", "title"}).CloseError(fmt.Errorf("close error"))
+	mock.ExpectQuery("SELECT").WillReturnRows(rows)
+
+	rs, _ := db.Query("SELECT")
+
+	// Note: that close will return error only before rows EOF
+	// that is a default sql package behavior. If you run rs.Next()
+	// it will handle the error internally and return nil bellow
+	if err := rs.Close(); err != nil {
+		fmt.Println("got error:", err)
+	}
+
+	// Output: got error: close error
+}
+
+func TestAllowsToSetRowsErrors(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rows := NewRows([]string{"id", "title"}).
+		AddRow(0, "one").
+		AddRow(1, "two").
+		RowError(1, fmt.Errorf("error"))
+	mock.ExpectQuery("SELECT").WillReturnRows(rows)
+
+	rs, err := db.Query("SELECT")
+	if err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+	defer rs.Close()
+
+	if !rs.Next() {
+		t.Fatal("expected the first row to be available")
+	}
+	if rs.Err() != nil {
+		t.Fatalf("unexpected error: %s", rs.Err())
+	}
+
+	if rs.Next() {
+		t.Fatal("was not expecting the second row, since there should be an error")
+	}
+	if rs.Err() == nil {
+		t.Fatal("expected an error, but got none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestRowsCloseError(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rows := NewRows([]string{"id"}).CloseError(fmt.Errorf("close error"))
+	mock.ExpectQuery("SELECT").WillReturnRows(rows)
+
+	rs, err := db.Query("SELECT")
+	if err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	if err := rs.Close(); err == nil {
+		t.Fatal("expected a close error")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestQuerySingleRow(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rows := NewRows([]string{"id"}).
+		AddRow(1).
+		AddRow(2)
+	mock.ExpectQuery("SELECT").WillReturnRows(rows)
+
+	var id int
+	if err := db.QueryRow("SELECT").Scan(&id); err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	mock.ExpectQuery("SELECT").WillReturnRows(NewRows([]string{"id"}))
+	if err := db.QueryRow("SELECT").Scan(&id); err != sql.ErrNoRows {
+		t.Fatal("expected sql no rows error")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestRowsScanError(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	r := NewRows([]string{"col1", "col2"}).AddRow("one", "two").AddRow("one", nil)
+	mock.ExpectQuery("SELECT").WillReturnRows(r)
+
+	rs, err := db.Query("SELECT")
+	if err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+	defer rs.Close()
+
+	var one, two string
+	if !rs.Next() || rs.Err() != nil || rs.Scan(&one, &two) != nil {
+		t.Fatal("unexpected error on first row scan")
+	}
+
+	if !rs.Next() || rs.Err() != nil {
+		t.Fatal("unexpected error on second row read")
+	}
+
+	err = rs.Scan(&one, &two)
+	if err == nil {
+		t.Fatal("expected an error for scan, but got none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestCSVRowParser(t *testing.T) {
+	t.Parallel()
+	rs := NewRows([]string{"col1", "col2"}).FromCSVString("a,NULL")
+	db, mock, err := New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectQuery("SELECT").WillReturnRows(rs)
+
+	rw, err := db.Query("SELECT")
+	if err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+	defer rw.Close()
+	var col1 string
+	var col2 []byte
+
+	rw.Next()
+	if err = rw.Scan(&col1, &col2); err != nil {
+		t.Fatalf("unexpected error: %s", err)
+	}
+	if col1 != "a" {
+		t.Fatalf("expected col1 to be 'a', but got [%T]:%+v", col1, col1)
+	}
+	if col2 != nil {
+		t.Fatalf("expected col2 to be nil, but got [%T]:%+v", col2, col2)
+	}
+}
+
+func TestWrongNumberOfValues(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	defer db.Close()
+	defer func() {
+		recover()
+	}()
+	mock.ExpectQuery("SELECT ID FROM TABLE").WithArgs(101).WillReturnRows(NewRows([]string{"ID"}).AddRow(101, "Hello"))
+	db.Query("SELECT ID FROM TABLE", 101)
+	// shouldn't reach here
+	t.Error("expected panic from query")
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock.go
new file mode 100644
index 0000000..b906a3f
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock.go
@@ -0,0 +1,525 @@
+/*
+Package sqlmock is a mock library implementing sql driver. Which has one and only
+purpose - to simulate any sql driver behavior in tests, without needing a real
+database connection. It helps to maintain correct **TDD** workflow.
+
+It does not require any modifications to your source code in order to test
+and mock database operations. Supports concurrency and multiple database mocking.
+
+The driver allows to mock any sql driver method behavior.
+*/
+package sqlmock
+
+import (
+	"database/sql"
+	"database/sql/driver"
+	"fmt"
+	"regexp"
+	"time"
+)
+
+// Sqlmock interface serves to create expectations
+// for any kind of database action in order to mock
+// and test real database behavior.
+type Sqlmock interface {
+
+	// ExpectClose queues an expectation for this database
+	// action to be triggered. the *ExpectedClose allows
+	// to mock database response
+	ExpectClose() *ExpectedClose
+
+	// ExpectationsWereMet checks whether all queued expectations
+	// were met in order. If any of them was not met - an error is returned.
+	ExpectationsWereMet() error
+
+	// ExpectPrepare expects Prepare() to be called with sql query
+	// which match sqlRegexStr given regexp.
+	// the *ExpectedPrepare allows to mock database response.
+	// Note that you may expect Query() or Exec() on the *ExpectedPrepare
+	// statement to prevent repeating sqlRegexStr
+	ExpectPrepare(sqlRegexStr string) *ExpectedPrepare
+
+	// ExpectQuery expects Query() or QueryRow() to be called with sql query
+	// which match sqlRegexStr given regexp.
+	// the *ExpectedQuery allows to mock database response.
+	ExpectQuery(sqlRegexStr string) *ExpectedQuery
+
+	// ExpectExec expects Exec() to be called with sql query
+	// which match sqlRegexStr given regexp.
+	// the *ExpectedExec allows to mock database response
+	ExpectExec(sqlRegexStr string) *ExpectedExec
+
+	// ExpectBegin expects *sql.DB.Begin to be called.
+	// the *ExpectedBegin allows to mock database response
+	ExpectBegin() *ExpectedBegin
+
+	// ExpectCommit expects *sql.Tx.Commit to be called.
+	// the *ExpectedCommit allows to mock database response
+	ExpectCommit() *ExpectedCommit
+
+	// ExpectRollback expects *sql.Tx.Rollback to be called.
+	// the *ExpectedRollback allows to mock database response
+	ExpectRollback() *ExpectedRollback
+
+	// MatchExpectationsInOrder gives an option whether to match all
+	// expectations in the order they were set or not.
+	//
+	// By default it is set to - true. But if you use goroutines
+	// to parallelize your query executation, that option may
+	// be handy.
+	//
+	// This option may be turned on anytime during tests. As soon
+	// as it is switched to false, expectations will be matched
+	// in any order. Or otherwise if switched to true, any unmatched
+	// expectations will be expected in order
+	MatchExpectationsInOrder(bool)
+}
+
+type sqlmock struct {
+	ordered bool
+	dsn     string
+	opened  int
+	drv     *mockDriver
+
+	expected []expectation
+}
+
+func (c *sqlmock) open() (*sql.DB, Sqlmock, error) {
+	db, err := sql.Open("sqlmock", c.dsn)
+	if err != nil {
+		return db, c, err
+	}
+	return db, c, db.Ping()
+}
+
+func (c *sqlmock) ExpectClose() *ExpectedClose {
+	e := &ExpectedClose{}
+	c.expected = append(c.expected, e)
+	return e
+}
+
+func (c *sqlmock) MatchExpectationsInOrder(b bool) {
+	c.ordered = b
+}
+
+// Close a mock database driver connection. It may or may not
+// be called depending on the sircumstances, but if it is called
+// there must be an *ExpectedClose expectation satisfied.
+// meets http://golang.org/pkg/database/sql/driver/#Conn interface
+func (c *sqlmock) Close() error {
+	c.drv.Lock()
+	defer c.drv.Unlock()
+
+	c.opened--
+	if c.opened == 0 {
+		delete(c.drv.conns, c.dsn)
+	}
+
+	var expected *ExpectedClose
+	var fulfilled int
+	var ok bool
+	for _, next := range c.expected {
+		next.Lock()
+		if next.fulfilled() {
+			next.Unlock()
+			fulfilled++
+			continue
+		}
+
+		if expected, ok = next.(*ExpectedClose); ok {
+			break
+		}
+
+		next.Unlock()
+		if c.ordered {
+			return fmt.Errorf("call to database Close, was not expected, next expectation is: %s", next)
+		}
+	}
+
+	if expected == nil {
+		msg := "call to database Close was not expected"
+		if fulfilled == len(c.expected) {
+			msg = "all expectations were already fulfilled, " + msg
+		}
+		return fmt.Errorf(msg)
+	}
+
+	expected.triggered = true
+	expected.Unlock()
+	return expected.err
+}
+
+func (c *sqlmock) ExpectationsWereMet() error {
+	for _, e := range c.expected {
+		if !e.fulfilled() {
+			return fmt.Errorf("there is a remaining expectation which was not matched: %s", e)
+		}
+	}
+	return nil
+}
+
+// Begin meets http://golang.org/pkg/database/sql/driver/#Conn interface
+func (c *sqlmock) Begin() (driver.Tx, error) {
+	ex, err := c.begin()
+	if err != nil {
+		return nil, err
+	}
+
+	time.Sleep(ex.delay)
+	return c, nil
+}
+
+func (c *sqlmock) begin() (*ExpectedBegin, error) {
+	var expected *ExpectedBegin
+	var ok bool
+	var fulfilled int
+	for _, next := range c.expected {
+		next.Lock()
+		if next.fulfilled() {
+			next.Unlock()
+			fulfilled++
+			continue
+		}
+
+		if expected, ok = next.(*ExpectedBegin); ok {
+			break
+		}
+
+		next.Unlock()
+		if c.ordered {
+			return nil, fmt.Errorf("call to database transaction Begin, was not expected, next expectation is: %s", next)
+		}
+	}
+	if expected == nil {
+		msg := "call to database transaction Begin was not expected"
+		if fulfilled == len(c.expected) {
+			msg = "all expectations were already fulfilled, " + msg
+		}
+		return nil, fmt.Errorf(msg)
+	}
+
+	expected.triggered = true
+	expected.Unlock()
+
+	return expected, expected.err
+}
+
+func (c *sqlmock) ExpectBegin() *ExpectedBegin {
+	e := &ExpectedBegin{}
+	c.expected = append(c.expected, e)
+	return e
+}
+
+// Exec meets http://golang.org/pkg/database/sql/driver/#Execer
+func (c *sqlmock) Exec(query string, args []driver.Value) (driver.Result, error) {
+	namedArgs := make([]namedValue, len(args))
+	for i, v := range args {
+		namedArgs[i] = namedValue{
+			Ordinal: i + 1,
+			Value:   v,
+		}
+	}
+
+	ex, err := c.exec(query, namedArgs)
+	if err != nil {
+		return nil, err
+	}
+
+	time.Sleep(ex.delay)
+	return ex.result, nil
+}
+
+func (c *sqlmock) exec(query string, args []namedValue) (*ExpectedExec, error) {
+	query = stripQuery(query)
+	var expected *ExpectedExec
+	var fulfilled int
+	var ok bool
+	for _, next := range c.expected {
+		next.Lock()
+		if next.fulfilled() {
+			next.Unlock()
+			fulfilled++
+			continue
+		}
+
+		if c.ordered {
+			if expected, ok = next.(*ExpectedExec); ok {
+				break
+			}
+			next.Unlock()
+			return nil, fmt.Errorf("call to exec query '%s' with args %+v, was not expected, next expectation is: %s", query, args, next)
+		}
+		if exec, ok := next.(*ExpectedExec); ok {
+			if err := exec.attemptMatch(query, args); err == nil {
+				expected = exec
+				break
+			}
+		}
+		next.Unlock()
+	}
+	if expected == nil {
+		msg := "call to exec '%s' query with args %+v was not expected"
+		if fulfilled == len(c.expected) {
+			msg = "all expectations were already fulfilled, " + msg
+		}
+		return nil, fmt.Errorf(msg, query, args)
+	}
+	defer expected.Unlock()
+
+	if !expected.queryMatches(query) {
+		return nil, fmt.Errorf("exec query '%s', does not match regex '%s'", query, expected.sqlRegex.String())
+	}
+
+	if err := expected.argsMatches(args); err != nil {
+		return nil, fmt.Errorf("exec query '%s', arguments do not match: %s", query, err)
+	}
+
+	expected.triggered = true
+	if expected.err != nil {
+		return nil, expected.err // mocked to return error
+	}
+
+	if expected.result == nil {
+		return nil, fmt.Errorf("exec query '%s' with args %+v, must return a database/sql/driver.result, but it was not set for expectation %T as %+v", query, args, expected, expected)
+	}
+
+	return expected, nil
+}
+
+func (c *sqlmock) ExpectExec(sqlRegexStr string) *ExpectedExec {
+	e := &ExpectedExec{}
+	sqlRegexStr = stripQuery(sqlRegexStr)
+	e.sqlRegex = regexp.MustCompile(sqlRegexStr)
+	c.expected = append(c.expected, e)
+	return e
+}
+
+// Prepare meets http://golang.org/pkg/database/sql/driver/#Conn interface
+func (c *sqlmock) Prepare(query string) (driver.Stmt, error) {
+	ex, err := c.prepare(query)
+	if err != nil {
+		return nil, err
+	}
+
+	time.Sleep(ex.delay)
+	return &statement{c, query, ex.closeErr}, nil
+}
+
+func (c *sqlmock) prepare(query string) (*ExpectedPrepare, error) {
+	var expected *ExpectedPrepare
+	var fulfilled int
+	var ok bool
+	for _, next := range c.expected {
+		next.Lock()
+		if next.fulfilled() {
+			next.Unlock()
+			fulfilled++
+			continue
+		}
+
+		if expected, ok = next.(*ExpectedPrepare); ok {
+			break
+		}
+
+		next.Unlock()
+		if c.ordered {
+			return nil, fmt.Errorf("call to Prepare statement with query '%s', was not expected, next expectation is: %s", query, next)
+		}
+	}
+
+	query = stripQuery(query)
+	if expected == nil {
+		msg := "call to Prepare '%s' query was not expected"
+		if fulfilled == len(c.expected) {
+			msg = "all expectations were already fulfilled, " + msg
+		}
+		return nil, fmt.Errorf(msg, query)
+	}
+	defer expected.Unlock()
+	if !expected.sqlRegex.MatchString(query) {
+		return nil, fmt.Errorf("query '%s', does not match regex [%s]", query, expected.sqlRegex.String())
+	}
+
+	expected.triggered = true
+	return expected, expected.err
+}
+
+func (c *sqlmock) ExpectPrepare(sqlRegexStr string) *ExpectedPrepare {
+	sqlRegexStr = stripQuery(sqlRegexStr)
+	e := &ExpectedPrepare{sqlRegex: regexp.MustCompile(sqlRegexStr), mock: c}
+	c.expected = append(c.expected, e)
+	return e
+}
+
+type namedValue struct {
+	Name    string
+	Ordinal int
+	Value   driver.Value
+}
+
+// Query meets http://golang.org/pkg/database/sql/driver/#Queryer
+func (c *sqlmock) Query(query string, args []driver.Value) (driver.Rows, error) {
+	namedArgs := make([]namedValue, len(args))
+	for i, v := range args {
+		namedArgs[i] = namedValue{
+			Ordinal: i + 1,
+			Value:   v,
+		}
+	}
+
+	ex, err := c.query(query, namedArgs)
+	if err != nil {
+		return nil, err
+	}
+
+	time.Sleep(ex.delay)
+	return ex.rows, nil
+}
+
+func (c *sqlmock) query(query string, args []namedValue) (*ExpectedQuery, error) {
+	query = stripQuery(query)
+	var expected *ExpectedQuery
+	var fulfilled int
+	var ok bool
+	for _, next := range c.expected {
+		next.Lock()
+		if next.fulfilled() {
+			next.Unlock()
+			fulfilled++
+			continue
+		}
+
+		if c.ordered {
+			if expected, ok = next.(*ExpectedQuery); ok {
+				break
+			}
+			next.Unlock()
+			return nil, fmt.Errorf("call to query '%s' with args %+v, was not expected, next expectation is: %s", query, args, next)
+		}
+		if qr, ok := next.(*ExpectedQuery); ok {
+			if err := qr.attemptMatch(query, args); err == nil {
+				expected = qr
+				break
+			}
+		}
+		next.Unlock()
+	}
+
+	if expected == nil {
+		msg := "call to query '%s' with args %+v was not expected"
+		if fulfilled == len(c.expected) {
+			msg = "all expectations were already fulfilled, " + msg
+		}
+		return nil, fmt.Errorf(msg, query, args)
+	}
+
+	defer expected.Unlock()
+
+	if !expected.queryMatches(query) {
+		return nil, fmt.Errorf("query '%s', does not match regex [%s]", query, expected.sqlRegex.String())
+	}
+
+	if err := expected.argsMatches(args); err != nil {
+		return nil, fmt.Errorf("exec query '%s', arguments do not match: %s", query, err)
+	}
+
+	expected.triggered = true
+	if expected.err != nil {
+		return nil, expected.err // mocked to return error
+	}
+
+	if expected.rows == nil {
+		return nil, fmt.Errorf("query '%s' with args %+v, must return a database/sql/driver.rows, but it was not set for expectation %T as %+v", query, args, expected, expected)
+	}
+	return expected, nil
+}
+
+func (c *sqlmock) ExpectQuery(sqlRegexStr string) *ExpectedQuery {
+	e := &ExpectedQuery{}
+	sqlRegexStr = stripQuery(sqlRegexStr)
+	e.sqlRegex = regexp.MustCompile(sqlRegexStr)
+	c.expected = append(c.expected, e)
+	return e
+}
+
+func (c *sqlmock) ExpectCommit() *ExpectedCommit {
+	e := &ExpectedCommit{}
+	c.expected = append(c.expected, e)
+	return e
+}
+
+func (c *sqlmock) ExpectRollback() *ExpectedRollback {
+	e := &ExpectedRollback{}
+	c.expected = append(c.expected, e)
+	return e
+}
+
+// Commit meets http://golang.org/pkg/database/sql/driver/#Tx
+func (c *sqlmock) Commit() error {
+	var expected *ExpectedCommit
+	var fulfilled int
+	var ok bool
+	for _, next := range c.expected {
+		next.Lock()
+		if next.fulfilled() {
+			next.Unlock()
+			fulfilled++
+			continue
+		}
+
+		if expected, ok = next.(*ExpectedCommit); ok {
+			break
+		}
+
+		next.Unlock()
+		if c.ordered {
+			return fmt.Errorf("call to commit transaction, was not expected, next expectation is: %s", next)
+		}
+	}
+	if expected == nil {
+		msg := "call to commit transaction was not expected"
+		if fulfilled == len(c.expected) {
+			msg = "all expectations were already fulfilled, " + msg
+		}
+		return fmt.Errorf(msg)
+	}
+
+	expected.triggered = true
+	expected.Unlock()
+	return expected.err
+}
+
+// Rollback meets http://golang.org/pkg/database/sql/driver/#Tx
+func (c *sqlmock) Rollback() error {
+	var expected *ExpectedRollback
+	var fulfilled int
+	var ok bool
+	for _, next := range c.expected {
+		next.Lock()
+		if next.fulfilled() {
+			next.Unlock()
+			fulfilled++
+			continue
+		}
+
+		if expected, ok = next.(*ExpectedRollback); ok {
+			break
+		}
+
+		next.Unlock()
+		if c.ordered {
+			return fmt.Errorf("call to rollback transaction, was not expected, next expectation is: %s", next)
+		}
+	}
+	if expected == nil {
+		msg := "call to rollback transaction was not expected"
+		if fulfilled == len(c.expected) {
+			msg = "all expectations were already fulfilled, " + msg
+		}
+		return fmt.Errorf(msg)
+	}
+
+	expected.triggered = true
+	expected.Unlock()
+	return expected.err
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18.go
new file mode 100644
index 0000000..c49429c
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18.go
@@ -0,0 +1,101 @@
+// +build go1.8
+
+package sqlmock
+
+import (
+	"context"
+	"database/sql/driver"
+	"errors"
+	"time"
+)
+
+var ErrCancelled = errors.New("canceling query due to user request")
+
+// Implement the "QueryerContext" interface
+func (c *sqlmock) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
+	namedArgs := make([]namedValue, len(args))
+	for i, nv := range args {
+		namedArgs[i] = namedValue(nv)
+	}
+
+	ex, err := c.query(query, namedArgs)
+	if err != nil {
+		return nil, err
+	}
+
+	select {
+	case <-time.After(ex.delay):
+		return ex.rows, nil
+	case <-ctx.Done():
+		return nil, ErrCancelled
+	}
+}
+
+// Implement the "ExecerContext" interface
+func (c *sqlmock) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
+	namedArgs := make([]namedValue, len(args))
+	for i, nv := range args {
+		namedArgs[i] = namedValue(nv)
+	}
+
+	ex, err := c.exec(query, namedArgs)
+	if err != nil {
+		return nil, err
+	}
+
+	select {
+	case <-time.After(ex.delay):
+		return ex.result, nil
+	case <-ctx.Done():
+		return nil, ErrCancelled
+	}
+}
+
+// Implement the "ConnBeginTx" interface
+func (c *sqlmock) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
+	ex, err := c.begin()
+	if err != nil {
+		return nil, err
+	}
+
+	select {
+	case <-time.After(ex.delay):
+		return c, nil
+	case <-ctx.Done():
+		return nil, ErrCancelled
+	}
+}
+
+// Implement the "ConnPrepareContext" interface
+func (c *sqlmock) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
+	ex, err := c.prepare(query)
+	if err != nil {
+		return nil, err
+	}
+
+	select {
+	case <-time.After(ex.delay):
+		return &statement{c, query, ex.closeErr}, nil
+	case <-ctx.Done():
+		return nil, ErrCancelled
+	}
+}
+
+// Implement the "Pinger" interface
+// for now we do not have a Ping expectation
+// may be something for the future
+func (c *sqlmock) Ping(ctx context.Context) error {
+	return nil
+}
+
+// Implement the "StmtExecContext" interface
+func (stmt *statement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
+	return stmt.conn.ExecContext(ctx, stmt.query, args)
+}
+
+// Implement the "StmtQueryContext" interface
+func (stmt *statement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
+	return stmt.conn.QueryContext(ctx, stmt.query, args)
+}
+
+// @TODO maybe add ExpectedBegin.WithOptions(driver.TxOptions)

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18_test.go
new file mode 100644
index 0000000..9eadcb5
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_go18_test.go
@@ -0,0 +1,426 @@
+// +build go1.8
+
+package sqlmock
+
+import (
+	"context"
+	"database/sql"
+	"testing"
+	"time"
+)
+
+func TestContextExecCancel(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectExec("DELETE FROM users").
+		WillDelayFor(time.Second).
+		WillReturnResult(NewResult(1, 1))
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	_, err = db.ExecContext(ctx, "DELETE FROM users")
+	if err == nil {
+		t.Error("error was expected, but there was none")
+	}
+
+	if err != ErrCancelled {
+		t.Errorf("was expecting cancel error, but got: %v", err)
+	}
+
+	_, err = db.ExecContext(ctx, "DELETE FROM users")
+	if err != context.Canceled {
+		t.Error("error was expected since context was already done, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestPreparedStatementContextExecCancel(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectPrepare("DELETE FROM users").
+		ExpectExec().
+		WillDelayFor(time.Second).
+		WillReturnResult(NewResult(1, 1))
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	stmt, err := db.Prepare("DELETE FROM users")
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	_, err = stmt.ExecContext(ctx)
+	if err == nil {
+		t.Error("error was expected, but there was none")
+	}
+
+	if err != ErrCancelled {
+		t.Errorf("was expecting cancel error, but got: %v", err)
+	}
+
+	_, err = stmt.ExecContext(ctx)
+	if err != context.Canceled {
+		t.Error("error was expected since context was already done, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextExecWithNamedArg(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectExec("DELETE FROM users").
+		WithArgs(sql.Named("id", 5)).
+		WillDelayFor(time.Second).
+		WillReturnResult(NewResult(1, 1))
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	_, err = db.ExecContext(ctx, "DELETE FROM users WHERE id = :id", sql.Named("id", 5))
+	if err == nil {
+		t.Error("error was expected, but there was none")
+	}
+
+	if err != ErrCancelled {
+		t.Errorf("was expecting cancel error, but got: %v", err)
+	}
+
+	_, err = db.ExecContext(ctx, "DELETE FROM users WHERE id = :id", sql.Named("id", 5))
+	if err != context.Canceled {
+		t.Error("error was expected since context was already done, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextExec(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectExec("DELETE FROM users").
+		WillReturnResult(NewResult(1, 1))
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	res, err := db.ExecContext(ctx, "DELETE FROM users")
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	affected, err := res.RowsAffected()
+	if affected != 1 {
+		t.Errorf("expected affected rows 1, but got %v", affected)
+	}
+
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextQueryCancel(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
+
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
+		WithArgs(5).
+		WillDelayFor(time.Second).
+		WillReturnRows(rs)
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	_, err = db.QueryContext(ctx, "SELECT id, title FROM articles WHERE id = ?", 5)
+	if err == nil {
+		t.Error("error was expected, but there was none")
+	}
+
+	if err != ErrCancelled {
+		t.Errorf("was expecting cancel error, but got: %v", err)
+	}
+
+	_, err = db.QueryContext(ctx, "SELECT id, title FROM articles WHERE id = ?", 5)
+	if err != context.Canceled {
+		t.Error("error was expected since context was already done, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestPreparedStatementContextQueryCancel(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
+
+	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?").
+		ExpectQuery().
+		WithArgs(5).
+		WillDelayFor(time.Second).
+		WillReturnRows(rs)
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	stmt, err := db.Prepare("SELECT id, title FROM articles WHERE id = ?")
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	_, err = stmt.QueryContext(ctx, 5)
+	if err == nil {
+		t.Error("error was expected, but there was none")
+	}
+
+	if err != ErrCancelled {
+		t.Errorf("was expecting cancel error, but got: %v", err)
+	}
+
+	_, err = stmt.QueryContext(ctx, 5)
+	if err != context.Canceled {
+		t.Error("error was expected since context was already done, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextQuery(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs := NewRows([]string{"id", "title"}).AddRow(5, "hello world")
+
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id =").
+		WithArgs(sql.Named("id", 5)).
+		WillDelayFor(time.Millisecond * 3).
+		WillReturnRows(rs)
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	rows, err := db.QueryContext(ctx, "SELECT id, title FROM articles WHERE id = :id", sql.Named("id", 5))
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	if !rows.Next() {
+		t.Error("expected one row, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextBeginCancel(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectBegin().WillDelayFor(time.Second)
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	_, err = db.BeginTx(ctx, nil)
+	if err == nil {
+		t.Error("error was expected, but there was none")
+	}
+
+	if err != ErrCancelled {
+		t.Errorf("was expecting cancel error, but got: %v", err)
+	}
+
+	_, err = db.BeginTx(ctx, nil)
+	if err != context.Canceled {
+		t.Error("error was expected since context was already done, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextBegin(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectBegin().WillDelayFor(time.Millisecond * 3)
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	tx, err := db.BeginTx(ctx, nil)
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	if tx == nil {
+		t.Error("expected tx, but there was nil")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextPrepareCancel(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectPrepare("SELECT").WillDelayFor(time.Second)
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	_, err = db.PrepareContext(ctx, "SELECT")
+	if err == nil {
+		t.Error("error was expected, but there was none")
+	}
+
+	if err != ErrCancelled {
+		t.Errorf("was expecting cancel error, but got: %v", err)
+	}
+
+	_, err = db.PrepareContext(ctx, "SELECT")
+	if err != context.Canceled {
+		t.Error("error was expected since context was already done, but there was none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestContextPrepare(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectPrepare("SELECT").WillDelayFor(time.Millisecond * 3)
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	go func() {
+		time.Sleep(time.Millisecond * 10)
+		cancel()
+	}()
+
+	stmt, err := db.PrepareContext(ctx, "SELECT")
+	if err != nil {
+		t.Errorf("error was not expected, but got: %v", err)
+	}
+
+	if stmt == nil {
+		t.Error("expected stmt, but there was nil")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}


[4/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify_test.go
new file mode 100644
index 0000000..82a77e1
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify_test.go
@@ -0,0 +1,564 @@
+package pq
+
+import (
+	"errors"
+	"fmt"
+	"io"
+	"os"
+	"runtime"
+	"sync"
+	"testing"
+	"time"
+)
+
+var errNilNotification = errors.New("nil notification")
+
+func expectNotification(t *testing.T, ch <-chan *Notification, relname string, extra string) error {
+	select {
+	case n := <-ch:
+		if n == nil {
+			return errNilNotification
+		}
+		if n.Channel != relname || n.Extra != extra {
+			return fmt.Errorf("unexpected notification %v", n)
+		}
+		return nil
+	case <-time.After(1500 * time.Millisecond):
+		return fmt.Errorf("timeout")
+	}
+}
+
+func expectNoNotification(t *testing.T, ch <-chan *Notification) error {
+	select {
+	case n := <-ch:
+		return fmt.Errorf("unexpected notification %v", n)
+	case <-time.After(100 * time.Millisecond):
+		return nil
+	}
+}
+
+func expectEvent(t *testing.T, eventch <-chan ListenerEventType, et ListenerEventType) error {
+	select {
+	case e := <-eventch:
+		if e != et {
+			return fmt.Errorf("unexpected event %v", e)
+		}
+		return nil
+	case <-time.After(1500 * time.Millisecond):
+		panic("expectEvent timeout")
+	}
+}
+
+func expectNoEvent(t *testing.T, eventch <-chan ListenerEventType) error {
+	select {
+	case e := <-eventch:
+		return fmt.Errorf("unexpected event %v", e)
+	case <-time.After(100 * time.Millisecond):
+		return nil
+	}
+}
+
+func newTestListenerConn(t *testing.T) (*ListenerConn, <-chan *Notification) {
+	datname := os.Getenv("PGDATABASE")
+	sslmode := os.Getenv("PGSSLMODE")
+
+	if datname == "" {
+		os.Setenv("PGDATABASE", "pqgotest")
+	}
+
+	if sslmode == "" {
+		os.Setenv("PGSSLMODE", "disable")
+	}
+
+	notificationChan := make(chan *Notification)
+	l, err := NewListenerConn("", notificationChan)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	return l, notificationChan
+}
+
+func TestNewListenerConn(t *testing.T) {
+	l, _ := newTestListenerConn(t)
+
+	defer l.Close()
+}
+
+func TestConnListen(t *testing.T) {
+	l, channel := newTestListenerConn(t)
+
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	ok, err := l.Listen("notify_test")
+	if !ok || err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, channel, "notify_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestConnUnlisten(t *testing.T) {
+	l, channel := newTestListenerConn(t)
+
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	ok, err := l.Listen("notify_test")
+	if !ok || err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_test")
+
+	err = expectNotification(t, channel, "notify_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	ok, err = l.Unlisten("notify_test")
+	if !ok || err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNoNotification(t, channel)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestConnUnlistenAll(t *testing.T) {
+	l, channel := newTestListenerConn(t)
+
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	ok, err := l.Listen("notify_test")
+	if !ok || err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_test")
+
+	err = expectNotification(t, channel, "notify_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	ok, err = l.UnlistenAll()
+	if !ok || err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNoNotification(t, channel)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestConnClose(t *testing.T) {
+	l, _ := newTestListenerConn(t)
+	defer l.Close()
+
+	err := l.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+	err = l.Close()
+	if err != errListenerConnClosed {
+		t.Fatalf("expected errListenerConnClosed; got %v", err)
+	}
+}
+
+func TestConnPing(t *testing.T) {
+	l, _ := newTestListenerConn(t)
+	defer l.Close()
+	err := l.Ping()
+	if err != nil {
+		t.Fatal(err)
+	}
+	err = l.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+	err = l.Ping()
+	if err != errListenerConnClosed {
+		t.Fatalf("expected errListenerConnClosed; got %v", err)
+	}
+}
+
+// Test for deadlock where a query fails while another one is queued
+func TestConnExecDeadlock(t *testing.T) {
+	l, _ := newTestListenerConn(t)
+	defer l.Close()
+
+	var wg sync.WaitGroup
+	wg.Add(2)
+
+	go func() {
+		l.ExecSimpleQuery("SELECT pg_sleep(60)")
+		wg.Done()
+	}()
+	runtime.Gosched()
+	go func() {
+		l.ExecSimpleQuery("SELECT 1")
+		wg.Done()
+	}()
+	// give the two goroutines some time to get into position
+	runtime.Gosched()
+	// calls Close on the net.Conn; equivalent to a network failure
+	l.Close()
+
+	defer time.AfterFunc(10*time.Second, func() {
+		panic("timed out")
+	}).Stop()
+	wg.Wait()
+}
+
+// Test for ListenerConn being closed while a slow query is executing
+func TestListenerConnCloseWhileQueryIsExecuting(t *testing.T) {
+	l, _ := newTestListenerConn(t)
+	defer l.Close()
+
+	var wg sync.WaitGroup
+	wg.Add(1)
+
+	go func() {
+		sent, err := l.ExecSimpleQuery("SELECT pg_sleep(60)")
+		if sent {
+			panic("expected sent=false")
+		}
+		// could be any of a number of errors
+		if err == nil {
+			panic("expected error")
+		}
+		wg.Done()
+	}()
+	// give the above goroutine some time to get into position
+	runtime.Gosched()
+	err := l.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	defer time.AfterFunc(10*time.Second, func() {
+		panic("timed out")
+	}).Stop()
+	wg.Wait()
+}
+
+func TestNotifyExtra(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	if getServerVersion(t, db) < 90000 {
+		t.Skip("skipping NOTIFY payload test since the server does not appear to support it")
+	}
+
+	l, channel := newTestListenerConn(t)
+	defer l.Close()
+
+	ok, err := l.Listen("notify_test")
+	if !ok || err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_test, 'something'")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, channel, "notify_test", "something")
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+// create a new test listener and also set the timeouts
+func newTestListenerTimeout(t *testing.T, min time.Duration, max time.Duration) (*Listener, <-chan ListenerEventType) {
+	datname := os.Getenv("PGDATABASE")
+	sslmode := os.Getenv("PGSSLMODE")
+
+	if datname == "" {
+		os.Setenv("PGDATABASE", "pqgotest")
+	}
+
+	if sslmode == "" {
+		os.Setenv("PGSSLMODE", "disable")
+	}
+
+	eventch := make(chan ListenerEventType, 16)
+	l := NewListener("", min, max, func(t ListenerEventType, err error) { eventch <- t })
+	err := expectEvent(t, eventch, ListenerEventConnected)
+	if err != nil {
+		t.Fatal(err)
+	}
+	return l, eventch
+}
+
+func newTestListener(t *testing.T) (*Listener, <-chan ListenerEventType) {
+	return newTestListenerTimeout(t, time.Hour, time.Hour)
+}
+
+func TestListenerListen(t *testing.T) {
+	l, _ := newTestListener(t)
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	err := l.Listen("notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, l.Notify, "notify_listen_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestListenerUnlisten(t *testing.T) {
+	l, _ := newTestListener(t)
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	err := l.Listen("notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = l.Unlisten("notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, l.Notify, "notify_listen_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNoNotification(t, l.Notify)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestListenerUnlistenAll(t *testing.T) {
+	l, _ := newTestListener(t)
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	err := l.Listen("notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = l.UnlistenAll()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, l.Notify, "notify_listen_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNoNotification(t, l.Notify)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestListenerFailedQuery(t *testing.T) {
+	l, eventch := newTestListener(t)
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	err := l.Listen("notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, l.Notify, "notify_listen_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	// shouldn't cause a disconnect
+	ok, err := l.cn.ExecSimpleQuery("SELECT error")
+	if !ok {
+		t.Fatalf("could not send query to server: %v", err)
+	}
+	_, ok = err.(PGError)
+	if !ok {
+		t.Fatalf("unexpected error %v", err)
+	}
+	err = expectNoEvent(t, eventch)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	// should still work
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, l.Notify, "notify_listen_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestListenerReconnect(t *testing.T) {
+	l, eventch := newTestListenerTimeout(t, 20*time.Millisecond, time.Hour)
+	defer l.Close()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	err := l.Listen("notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, l.Notify, "notify_listen_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	// kill the connection and make sure it comes back up
+	ok, err := l.cn.ExecSimpleQuery("SELECT pg_terminate_backend(pg_backend_pid())")
+	if ok {
+		t.Fatalf("could not kill the connection: %v", err)
+	}
+	if err != io.EOF {
+		t.Fatalf("unexpected error %v", err)
+	}
+	err = expectEvent(t, eventch, ListenerEventDisconnected)
+	if err != nil {
+		t.Fatal(err)
+	}
+	err = expectEvent(t, eventch, ListenerEventReconnected)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	// should still work
+	_, err = db.Exec("NOTIFY notify_listen_test")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	// should get nil after Reconnected
+	err = expectNotification(t, l.Notify, "", "")
+	if err != errNilNotification {
+		t.Fatal(err)
+	}
+
+	err = expectNotification(t, l.Notify, "notify_listen_test", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestListenerClose(t *testing.T) {
+	l, _ := newTestListenerTimeout(t, 20*time.Millisecond, time.Hour)
+	defer l.Close()
+
+	err := l.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+	err = l.Close()
+	if err != errListenerClosed {
+		t.Fatalf("expected errListenerClosed; got %v", err)
+	}
+}
+
+func TestListenerPing(t *testing.T) {
+	l, _ := newTestListenerTimeout(t, 20*time.Millisecond, time.Hour)
+	defer l.Close()
+
+	err := l.Ping()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = l.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = l.Ping()
+	if err != errListenerClosed {
+		t.Fatalf("expected errListenerClosed; got %v", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/doc.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/doc.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/doc.go
new file mode 100644
index 0000000..caaede2
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/doc.go
@@ -0,0 +1,6 @@
+// Package oid contains OID constants
+// as defined by the Postgres server.
+package oid
+
+// Oid is a Postgres Object ID.
+type Oid uint32

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/gen.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/gen.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/gen.go
new file mode 100644
index 0000000..cd4aea8
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/gen.go
@@ -0,0 +1,74 @@
+// +build ignore
+
+// Generate the table of OID values
+// Run with 'go run gen.go'.
+package main
+
+import (
+	"database/sql"
+	"fmt"
+	"log"
+	"os"
+	"os/exec"
+
+	_ "github.com/lib/pq"
+)
+
+func main() {
+	datname := os.Getenv("PGDATABASE")
+	sslmode := os.Getenv("PGSSLMODE")
+
+	if datname == "" {
+		os.Setenv("PGDATABASE", "pqgotest")
+	}
+
+	if sslmode == "" {
+		os.Setenv("PGSSLMODE", "disable")
+	}
+
+	db, err := sql.Open("postgres", "")
+	if err != nil {
+		log.Fatal(err)
+	}
+	cmd := exec.Command("gofmt")
+	cmd.Stderr = os.Stderr
+	w, err := cmd.StdinPipe()
+	if err != nil {
+		log.Fatal(err)
+	}
+	f, err := os.Create("types.go")
+	if err != nil {
+		log.Fatal(err)
+	}
+	cmd.Stdout = f
+	err = cmd.Start()
+	if err != nil {
+		log.Fatal(err)
+	}
+	fmt.Fprintln(w, "// generated by 'go run gen.go'; do not edit")
+	fmt.Fprintln(w, "\npackage oid")
+	fmt.Fprintln(w, "const (")
+	rows, err := db.Query(`
+		SELECT typname, oid
+		FROM pg_type WHERE oid < 10000
+		ORDER BY oid;
+	`)
+	if err != nil {
+		log.Fatal(err)
+	}
+	var name string
+	var oid int
+	for rows.Next() {
+		err = rows.Scan(&name, &oid)
+		if err != nil {
+			log.Fatal(err)
+		}
+		fmt.Fprintf(w, "T_%s Oid = %d\n", name, oid)
+	}
+	if err = rows.Err(); err != nil {
+		log.Fatal(err)
+	}
+	fmt.Fprintln(w, ")")
+	w.Close()
+	cmd.Wait()
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/types.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/types.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/types.go
new file mode 100644
index 0000000..a3390c2
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/oid/types.go
@@ -0,0 +1,173 @@
+// generated by 'go run gen.go'; do not edit
+
+package oid
+
+const (
+	T_bool             Oid = 16
+	T_bytea            Oid = 17
+	T_char             Oid = 18
+	T_name             Oid = 19
+	T_int8             Oid = 20
+	T_int2             Oid = 21
+	T_int2vector       Oid = 22
+	T_int4             Oid = 23
+	T_regproc          Oid = 24
+	T_text             Oid = 25
+	T_oid              Oid = 26
+	T_tid              Oid = 27
+	T_xid              Oid = 28
+	T_cid              Oid = 29
+	T_oidvector        Oid = 30
+	T_pg_ddl_command   Oid = 32
+	T_pg_type          Oid = 71
+	T_pg_attribute     Oid = 75
+	T_pg_proc          Oid = 81
+	T_pg_class         Oid = 83
+	T_json             Oid = 114
+	T_xml              Oid = 142
+	T__xml             Oid = 143
+	T_pg_node_tree     Oid = 194
+	T__json            Oid = 199
+	T_smgr             Oid = 210
+	T_index_am_handler Oid = 325
+	T_point            Oid = 600
+	T_lseg             Oid = 601
+	T_path             Oid = 602
+	T_box              Oid = 603
+	T_polygon          Oid = 604
+	T_line             Oid = 628
+	T__line            Oid = 629
+	T_cidr             Oid = 650
+	T__cidr            Oid = 651
+	T_float4           Oid = 700
+	T_float8           Oid = 701
+	T_abstime          Oid = 702
+	T_reltime          Oid = 703
+	T_tinterval        Oid = 704
+	T_unknown          Oid = 705
+	T_circle           Oid = 718
+	T__circle          Oid = 719
+	T_money            Oid = 790
+	T__money           Oid = 791
+	T_macaddr          Oid = 829
+	T_inet             Oid = 869
+	T__bool            Oid = 1000
+	T__bytea           Oid = 1001
+	T__char            Oid = 1002
+	T__name            Oid = 1003
+	T__int2            Oid = 1005
+	T__int2vector      Oid = 1006
+	T__int4            Oid = 1007
+	T__regproc         Oid = 1008
+	T__text            Oid = 1009
+	T__tid             Oid = 1010
+	T__xid             Oid = 1011
+	T__cid             Oid = 1012
+	T__oidvector       Oid = 1013
+	T__bpchar          Oid = 1014
+	T__varchar         Oid = 1015
+	T__int8            Oid = 1016
+	T__point           Oid = 1017
+	T__lseg            Oid = 1018
+	T__path            Oid = 1019
+	T__box             Oid = 1020
+	T__float4          Oid = 1021
+	T__float8          Oid = 1022
+	T__abstime         Oid = 1023
+	T__reltime         Oid = 1024
+	T__tinterval       Oid = 1025
+	T__polygon         Oid = 1027
+	T__oid             Oid = 1028
+	T_aclitem          Oid = 1033
+	T__aclitem         Oid = 1034
+	T__macaddr         Oid = 1040
+	T__inet            Oid = 1041
+	T_bpchar           Oid = 1042
+	T_varchar          Oid = 1043
+	T_date             Oid = 1082
+	T_time             Oid = 1083
+	T_timestamp        Oid = 1114
+	T__timestamp       Oid = 1115
+	T__date            Oid = 1182
+	T__time            Oid = 1183
+	T_timestamptz      Oid = 1184
+	T__timestamptz     Oid = 1185
+	T_interval         Oid = 1186
+	T__interval        Oid = 1187
+	T__numeric         Oid = 1231
+	T_pg_database      Oid = 1248
+	T__cstring         Oid = 1263
+	T_timetz           Oid = 1266
+	T__timetz          Oid = 1270
+	T_bit              Oid = 1560
+	T__bit             Oid = 1561
+	T_varbit           Oid = 1562
+	T__varbit          Oid = 1563
+	T_numeric          Oid = 1700
+	T_refcursor        Oid = 1790
+	T__refcursor       Oid = 2201
+	T_regprocedure     Oid = 2202
+	T_regoper          Oid = 2203
+	T_regoperator      Oid = 2204
+	T_regclass         Oid = 2205
+	T_regtype          Oid = 2206
+	T__regprocedure    Oid = 2207
+	T__regoper         Oid = 2208
+	T__regoperator     Oid = 2209
+	T__regclass        Oid = 2210
+	T__regtype         Oid = 2211
+	T_record           Oid = 2249
+	T_cstring          Oid = 2275
+	T_any              Oid = 2276
+	T_anyarray         Oid = 2277
+	T_void             Oid = 2278
+	T_trigger          Oid = 2279
+	T_language_handler Oid = 2280
+	T_internal         Oid = 2281
+	T_opaque           Oid = 2282
+	T_anyelement       Oid = 2283
+	T__record          Oid = 2287
+	T_anynonarray      Oid = 2776
+	T_pg_authid        Oid = 2842
+	T_pg_auth_members  Oid = 2843
+	T__txid_snapshot   Oid = 2949
+	T_uuid             Oid = 2950
+	T__uuid            Oid = 2951
+	T_txid_snapshot    Oid = 2970
+	T_fdw_handler      Oid = 3115
+	T_pg_lsn           Oid = 3220
+	T__pg_lsn          Oid = 3221
+	T_tsm_handler      Oid = 3310
+	T_anyenum          Oid = 3500
+	T_tsvector         Oid = 3614
+	T_tsquery          Oid = 3615
+	T_gtsvector        Oid = 3642
+	T__tsvector        Oid = 3643
+	T__gtsvector       Oid = 3644
+	T__tsquery         Oid = 3645
+	T_regconfig        Oid = 3734
+	T__regconfig       Oid = 3735
+	T_regdictionary    Oid = 3769
+	T__regdictionary   Oid = 3770
+	T_jsonb            Oid = 3802
+	T__jsonb           Oid = 3807
+	T_anyrange         Oid = 3831
+	T_event_trigger    Oid = 3838
+	T_int4range        Oid = 3904
+	T__int4range       Oid = 3905
+	T_numrange         Oid = 3906
+	T__numrange        Oid = 3907
+	T_tsrange          Oid = 3908
+	T__tsrange         Oid = 3909
+	T_tstzrange        Oid = 3910
+	T__tstzrange       Oid = 3911
+	T_daterange        Oid = 3912
+	T__daterange       Oid = 3913
+	T_int8range        Oid = 3926
+	T__int8range       Oid = 3927
+	T_pg_shseclabel    Oid = 4066
+	T_regnamespace     Oid = 4089
+	T__regnamespace    Oid = 4090
+	T_regrole          Oid = 4096
+	T__regrole         Oid = 4097
+)

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl.go
new file mode 100644
index 0000000..7deb304
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl.go
@@ -0,0 +1,158 @@
+package pq
+
+import (
+	"crypto/tls"
+	"crypto/x509"
+	"io/ioutil"
+	"net"
+	"os"
+	"os/user"
+	"path/filepath"
+)
+
+// ssl generates a function to upgrade a net.Conn based on the "sslmode" and
+// related settings. The function is nil when no upgrade should take place.
+func ssl(o values) func(net.Conn) net.Conn {
+	verifyCaOnly := false
+	tlsConf := tls.Config{}
+	switch mode := o["sslmode"]; mode {
+	// "require" is the default.
+	case "", "require":
+		// We must skip TLS's own verification since it requires full
+		// verification since Go 1.3.
+		tlsConf.InsecureSkipVerify = true
+
+		// From http://www.postgresql.org/docs/current/static/libpq-ssl.html:
+		//
+		// Note: For backwards compatibility with earlier versions of
+		// PostgreSQL, if a root CA file exists, the behavior of
+		// sslmode=require will be the same as that of verify-ca, meaning the
+		// server certificate is validated against the CA. Relying on this
+		// behavior is discouraged, and applications that need certificate
+		// validation should always use verify-ca or verify-full.
+		if sslrootcert, ok := o["sslrootcert"]; ok {
+			if _, err := os.Stat(sslrootcert); err == nil {
+				verifyCaOnly = true
+			} else {
+				delete(o, "sslrootcert")
+			}
+		}
+	case "verify-ca":
+		// We must skip TLS's own verification since it requires full
+		// verification since Go 1.3.
+		tlsConf.InsecureSkipVerify = true
+		verifyCaOnly = true
+	case "verify-full":
+		tlsConf.ServerName = o["host"]
+	case "disable":
+		return nil
+	default:
+		errorf(`unsupported sslmode %q; only "require" (default), "verify-full", "verify-ca", and "disable" supported`, mode)
+	}
+
+	sslClientCertificates(&tlsConf, o)
+	sslCertificateAuthority(&tlsConf, o)
+	sslRenegotiation(&tlsConf)
+
+	return func(conn net.Conn) net.Conn {
+		client := tls.Client(conn, &tlsConf)
+		if verifyCaOnly {
+			sslVerifyCertificateAuthority(client, &tlsConf)
+		}
+		return client
+	}
+}
+
+// sslClientCertificates adds the certificate specified in the "sslcert" and
+// "sslkey" settings, or if they aren't set, from the .postgresql directory
+// in the user's home directory. The configured files must exist and have
+// the correct permissions.
+func sslClientCertificates(tlsConf *tls.Config, o values) {
+	// user.Current() might fail when cross-compiling. We have to ignore the
+	// error and continue without home directory defaults, since we wouldn't
+	// know from where to load them.
+	user, _ := user.Current()
+
+	// In libpq, the client certificate is only loaded if the setting is not blank.
+	//
+	// https://github.com/postgres/postgres/blob/REL9_6_2/src/interfaces/libpq/fe-secure-openssl.c#L1036-L1037
+	sslcert := o["sslcert"]
+	if len(sslcert) == 0 && user != nil {
+		sslcert = filepath.Join(user.HomeDir, ".postgresql", "postgresql.crt")
+	}
+	// https://github.com/postgres/postgres/blob/REL9_6_2/src/interfaces/libpq/fe-secure-openssl.c#L1045
+	if len(sslcert) == 0 {
+		return
+	}
+	// https://github.com/postgres/postgres/blob/REL9_6_2/src/interfaces/libpq/fe-secure-openssl.c#L1050:L1054
+	if _, err := os.Stat(sslcert); os.IsNotExist(err) {
+		return
+	} else if err != nil {
+		panic(err)
+	}
+
+	// In libpq, the ssl key is only loaded if the setting is not blank.
+	//
+	// https://github.com/postgres/postgres/blob/REL9_6_2/src/interfaces/libpq/fe-secure-openssl.c#L1123-L1222
+	sslkey := o["sslkey"]
+	if len(sslkey) == 0 && user != nil {
+		sslkey = filepath.Join(user.HomeDir, ".postgresql", "postgresql.key")
+	}
+
+	if len(sslkey) > 0 {
+		if err := sslKeyPermissions(sslkey); err != nil {
+			panic(err)
+		}
+	}
+
+	cert, err := tls.LoadX509KeyPair(sslcert, sslkey)
+	if err != nil {
+		panic(err)
+	}
+	tlsConf.Certificates = []tls.Certificate{cert}
+}
+
+// sslCertificateAuthority adds the RootCA specified in the "sslrootcert" setting.
+func sslCertificateAuthority(tlsConf *tls.Config, o values) {
+	// In libpq, the root certificate is only loaded if the setting is not blank.
+	//
+	// https://github.com/postgres/postgres/blob/REL9_6_2/src/interfaces/libpq/fe-secure-openssl.c#L950-L951
+	if sslrootcert := o["sslrootcert"]; len(sslrootcert) > 0 {
+		tlsConf.RootCAs = x509.NewCertPool()
+
+		cert, err := ioutil.ReadFile(sslrootcert)
+		if err != nil {
+			panic(err)
+		}
+
+		if !tlsConf.RootCAs.AppendCertsFromPEM(cert) {
+			errorf("couldn't parse pem in sslrootcert")
+		}
+	}
+}
+
+// sslVerifyCertificateAuthority carries out a TLS handshake to the server and
+// verifies the presented certificate against the CA, i.e. the one specified in
+// sslrootcert or the system CA if sslrootcert was not specified.
+func sslVerifyCertificateAuthority(client *tls.Conn, tlsConf *tls.Config) {
+	err := client.Handshake()
+	if err != nil {
+		panic(err)
+	}
+	certs := client.ConnectionState().PeerCertificates
+	opts := x509.VerifyOptions{
+		DNSName:       client.ConnectionState().ServerName,
+		Intermediates: x509.NewCertPool(),
+		Roots:         tlsConf.RootCAs,
+	}
+	for i, cert := range certs {
+		if i == 0 {
+			continue
+		}
+		opts.Intermediates.AddCert(cert)
+	}
+	_, err = certs[0].Verify(opts)
+	if err != nil {
+		panic(err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_go1.7.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_go1.7.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_go1.7.go
new file mode 100644
index 0000000..d7ba43b
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_go1.7.go
@@ -0,0 +1,14 @@
+// +build go1.7
+
+package pq
+
+import "crypto/tls"
+
+// Accept renegotiation requests initiated by the backend.
+//
+// Renegotiation was deprecated then removed from PostgreSQL 9.5, but
+// the default configuration of older versions has it enabled. Redshift
+// also initiates renegotiations and cannot be reconfigured.
+func sslRenegotiation(conf *tls.Config) {
+	conf.Renegotiation = tls.RenegotiateFreelyAsClient
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_permissions.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_permissions.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_permissions.go
new file mode 100644
index 0000000..3b7c3a2
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_permissions.go
@@ -0,0 +1,20 @@
+// +build !windows
+
+package pq
+
+import "os"
+
+// sslKeyPermissions checks the permissions on user-supplied ssl key files.
+// The key file should have very little access.
+//
+// libpq does not check key file permissions on Windows.
+func sslKeyPermissions(sslkey string) error {
+	info, err := os.Stat(sslkey)
+	if err != nil {
+		return err
+	}
+	if info.Mode().Perm()&0077 != 0 {
+		return ErrSSLKeyHasWorldPermissions
+	}
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_renegotiation.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_renegotiation.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_renegotiation.go
new file mode 100644
index 0000000..85ed5e4
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_renegotiation.go
@@ -0,0 +1,8 @@
+// +build !go1.7
+
+package pq
+
+import "crypto/tls"
+
+// Renegotiation is not supported by crypto/tls until Go 1.7.
+func sslRenegotiation(*tls.Config) {}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_test.go
new file mode 100644
index 0000000..3eafbfd
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_test.go
@@ -0,0 +1,279 @@
+package pq
+
+// This file contains SSL tests
+
+import (
+	_ "crypto/sha256"
+	"crypto/x509"
+	"database/sql"
+	"os"
+	"path/filepath"
+	"testing"
+)
+
+func maybeSkipSSLTests(t *testing.T) {
+	// Require some special variables for testing certificates
+	if os.Getenv("PQSSLCERTTEST_PATH") == "" {
+		t.Skip("PQSSLCERTTEST_PATH not set, skipping SSL tests")
+	}
+
+	value := os.Getenv("PQGOSSLTESTS")
+	if value == "" || value == "0" {
+		t.Skip("PQGOSSLTESTS not enabled, skipping SSL tests")
+	} else if value != "1" {
+		t.Fatalf("unexpected value %q for PQGOSSLTESTS", value)
+	}
+}
+
+func openSSLConn(t *testing.T, conninfo string) (*sql.DB, error) {
+	db, err := openTestConnConninfo(conninfo)
+	if err != nil {
+		// should never fail
+		t.Fatal(err)
+	}
+	// Do something with the connection to see whether it's working or not.
+	tx, err := db.Begin()
+	if err == nil {
+		return db, tx.Rollback()
+	}
+	_ = db.Close()
+	return nil, err
+}
+
+func checkSSLSetup(t *testing.T, conninfo string) {
+	_, err := openSSLConn(t, conninfo)
+	if pge, ok := err.(*Error); ok {
+		if pge.Code.Name() != "invalid_authorization_specification" {
+			t.Fatalf("unexpected error code '%s'", pge.Code.Name())
+		}
+	} else {
+		t.Fatalf("expected %T, got %v", (*Error)(nil), err)
+	}
+}
+
+// Connect over SSL and run a simple query to test the basics
+func TestSSLConnection(t *testing.T) {
+	maybeSkipSSLTests(t)
+	// Environment sanity check: should fail without SSL
+	checkSSLSetup(t, "sslmode=disable user=pqgossltest")
+
+	db, err := openSSLConn(t, "sslmode=require user=pqgossltest")
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows, err := db.Query("SELECT 1")
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows.Close()
+}
+
+// Test sslmode=verify-full
+func TestSSLVerifyFull(t *testing.T) {
+	maybeSkipSSLTests(t)
+	// Environment sanity check: should fail without SSL
+	checkSSLSetup(t, "sslmode=disable user=pqgossltest")
+
+	// Not OK according to the system CA
+	_, err := openSSLConn(t, "host=postgres sslmode=verify-full user=pqgossltest")
+	if err == nil {
+		t.Fatal("expected error")
+	}
+	_, ok := err.(x509.UnknownAuthorityError)
+	if !ok {
+		t.Fatalf("expected x509.UnknownAuthorityError, got %#+v", err)
+	}
+
+	rootCertPath := filepath.Join(os.Getenv("PQSSLCERTTEST_PATH"), "root.crt")
+	rootCert := "sslrootcert=" + rootCertPath + " "
+	// No match on Common Name
+	_, err = openSSLConn(t, rootCert+"host=127.0.0.1 sslmode=verify-full user=pqgossltest")
+	if err == nil {
+		t.Fatal("expected error")
+	}
+	_, ok = err.(x509.HostnameError)
+	if !ok {
+		t.Fatalf("expected x509.HostnameError, got %#+v", err)
+	}
+	// OK
+	_, err = openSSLConn(t, rootCert+"host=postgres sslmode=verify-full user=pqgossltest")
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+// Test sslmode=require sslrootcert=rootCertPath
+func TestSSLRequireWithRootCert(t *testing.T) {
+	maybeSkipSSLTests(t)
+	// Environment sanity check: should fail without SSL
+	checkSSLSetup(t, "sslmode=disable user=pqgossltest")
+
+	bogusRootCertPath := filepath.Join(os.Getenv("PQSSLCERTTEST_PATH"), "bogus_root.crt")
+	bogusRootCert := "sslrootcert=" + bogusRootCertPath + " "
+
+	// Not OK according to the bogus CA
+	_, err := openSSLConn(t, bogusRootCert+"host=postgres sslmode=require user=pqgossltest")
+	if err == nil {
+		t.Fatal("expected error")
+	}
+	_, ok := err.(x509.UnknownAuthorityError)
+	if !ok {
+		t.Fatalf("expected x509.UnknownAuthorityError, got %s, %#+v", err, err)
+	}
+
+	nonExistentCertPath := filepath.Join(os.Getenv("PQSSLCERTTEST_PATH"), "non_existent.crt")
+	nonExistentCert := "sslrootcert=" + nonExistentCertPath + " "
+
+	// No match on Common Name, but that's OK because we're not validating anything.
+	_, err = openSSLConn(t, nonExistentCert+"host=127.0.0.1 sslmode=require user=pqgossltest")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	rootCertPath := filepath.Join(os.Getenv("PQSSLCERTTEST_PATH"), "root.crt")
+	rootCert := "sslrootcert=" + rootCertPath + " "
+
+	// No match on Common Name, but that's OK because we're not validating the CN.
+	_, err = openSSLConn(t, rootCert+"host=127.0.0.1 sslmode=require user=pqgossltest")
+	if err != nil {
+		t.Fatal(err)
+	}
+	// Everything OK
+	_, err = openSSLConn(t, rootCert+"host=postgres sslmode=require user=pqgossltest")
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+// Test sslmode=verify-ca
+func TestSSLVerifyCA(t *testing.T) {
+	maybeSkipSSLTests(t)
+	// Environment sanity check: should fail without SSL
+	checkSSLSetup(t, "sslmode=disable user=pqgossltest")
+
+	// Not OK according to the system CA
+	{
+		_, err := openSSLConn(t, "host=postgres sslmode=verify-ca user=pqgossltest")
+		if _, ok := err.(x509.UnknownAuthorityError); !ok {
+			t.Fatalf("expected %T, got %#+v", x509.UnknownAuthorityError{}, err)
+		}
+	}
+
+	// Still not OK according to the system CA; empty sslrootcert is treated as unspecified.
+	{
+		_, err := openSSLConn(t, "host=postgres sslmode=verify-ca user=pqgossltest sslrootcert=''")
+		if _, ok := err.(x509.UnknownAuthorityError); !ok {
+			t.Fatalf("expected %T, got %#+v", x509.UnknownAuthorityError{}, err)
+		}
+	}
+
+	rootCertPath := filepath.Join(os.Getenv("PQSSLCERTTEST_PATH"), "root.crt")
+	rootCert := "sslrootcert=" + rootCertPath + " "
+	// No match on Common Name, but that's OK
+	if _, err := openSSLConn(t, rootCert+"host=127.0.0.1 sslmode=verify-ca user=pqgossltest"); err != nil {
+		t.Fatal(err)
+	}
+	// Everything OK
+	if _, err := openSSLConn(t, rootCert+"host=postgres sslmode=verify-ca user=pqgossltest"); err != nil {
+		t.Fatal(err)
+	}
+}
+
+// Authenticate over SSL using client certificates
+func TestSSLClientCertificates(t *testing.T) {
+	maybeSkipSSLTests(t)
+	// Environment sanity check: should fail without SSL
+	checkSSLSetup(t, "sslmode=disable user=pqgossltest")
+
+	const baseinfo = "sslmode=require user=pqgosslcert"
+
+	// Certificate not specified, should fail
+	{
+		_, err := openSSLConn(t, baseinfo)
+		if pge, ok := err.(*Error); ok {
+			if pge.Code.Name() != "invalid_authorization_specification" {
+				t.Fatalf("unexpected error code '%s'", pge.Code.Name())
+			}
+		} else {
+			t.Fatalf("expected %T, got %v", (*Error)(nil), err)
+		}
+	}
+
+	// Empty certificate specified, should fail
+	{
+		_, err := openSSLConn(t, baseinfo+" sslcert=''")
+		if pge, ok := err.(*Error); ok {
+			if pge.Code.Name() != "invalid_authorization_specification" {
+				t.Fatalf("unexpected error code '%s'", pge.Code.Name())
+			}
+		} else {
+			t.Fatalf("expected %T, got %v", (*Error)(nil), err)
+		}
+	}
+
+	// Non-existent certificate specified, should fail
+	{
+		_, err := openSSLConn(t, baseinfo+" sslcert=/tmp/filedoesnotexist")
+		if pge, ok := err.(*Error); ok {
+			if pge.Code.Name() != "invalid_authorization_specification" {
+				t.Fatalf("unexpected error code '%s'", pge.Code.Name())
+			}
+		} else {
+			t.Fatalf("expected %T, got %v", (*Error)(nil), err)
+		}
+	}
+
+	certpath, ok := os.LookupEnv("PQSSLCERTTEST_PATH")
+	if !ok {
+		t.Fatalf("PQSSLCERTTEST_PATH not present in environment")
+	}
+
+	sslcert := filepath.Join(certpath, "postgresql.crt")
+
+	// Cert present, key not specified, should fail
+	{
+		_, err := openSSLConn(t, baseinfo+" sslcert="+sslcert)
+		if _, ok := err.(*os.PathError); !ok {
+			t.Fatalf("expected %T, got %#+v", (*os.PathError)(nil), err)
+		}
+	}
+
+	// Cert present, empty key specified, should fail
+	{
+		_, err := openSSLConn(t, baseinfo+" sslcert="+sslcert+" sslkey=''")
+		if _, ok := err.(*os.PathError); !ok {
+			t.Fatalf("expected %T, got %#+v", (*os.PathError)(nil), err)
+		}
+	}
+
+	// Cert present, non-existent key, should fail
+	{
+		_, err := openSSLConn(t, baseinfo+" sslcert="+sslcert+" sslkey=/tmp/filedoesnotexist")
+		if _, ok := err.(*os.PathError); !ok {
+			t.Fatalf("expected %T, got %#+v", (*os.PathError)(nil), err)
+		}
+	}
+
+	// Key has wrong permissions (passing the cert as the key), should fail
+	if _, err := openSSLConn(t, baseinfo+" sslcert="+sslcert+" sslkey="+sslcert); err != ErrSSLKeyHasWorldPermissions {
+		t.Fatalf("expected %s, got %#+v", ErrSSLKeyHasWorldPermissions, err)
+	}
+
+	sslkey := filepath.Join(certpath, "postgresql.key")
+
+	// Should work
+	if db, err := openSSLConn(t, baseinfo+" sslcert="+sslcert+" sslkey="+sslkey); err != nil {
+		t.Fatal(err)
+	} else {
+		rows, err := db.Query("SELECT 1")
+		if err != nil {
+			t.Fatal(err)
+		}
+		if err := rows.Close(); err != nil {
+			t.Fatal(err)
+		}
+		if err := db.Close(); err != nil {
+			t.Fatal(err)
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_windows.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_windows.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_windows.go
new file mode 100644
index 0000000..5d2c763
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/ssl_windows.go
@@ -0,0 +1,9 @@
+// +build windows
+
+package pq
+
+// sslKeyPermissions checks the permissions on user-supplied ssl key files.
+// The key file should have very little access.
+//
+// libpq does not check key file permissions on Windows.
+func sslKeyPermissions(string) error { return nil }

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url.go
new file mode 100644
index 0000000..f4d8a7c
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url.go
@@ -0,0 +1,76 @@
+package pq
+
+import (
+	"fmt"
+	"net"
+	nurl "net/url"
+	"sort"
+	"strings"
+)
+
+// ParseURL no longer needs to be used by clients of this library since supplying a URL as a
+// connection string to sql.Open() is now supported:
+//
+//	sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full")
+//
+// It remains exported here for backwards-compatibility.
+//
+// ParseURL converts a url to a connection string for driver.Open.
+// Example:
+//
+//	"postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full"
+//
+// converts to:
+//
+//	"user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full"
+//
+// A minimal example:
+//
+//	"postgres://"
+//
+// This will be blank, causing driver.Open to use all of the defaults
+func ParseURL(url string) (string, error) {
+	u, err := nurl.Parse(url)
+	if err != nil {
+		return "", err
+	}
+
+	if u.Scheme != "postgres" && u.Scheme != "postgresql" {
+		return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme)
+	}
+
+	var kvs []string
+	escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`)
+	accrue := func(k, v string) {
+		if v != "" {
+			kvs = append(kvs, k+"="+escaper.Replace(v))
+		}
+	}
+
+	if u.User != nil {
+		v := u.User.Username()
+		accrue("user", v)
+
+		v, _ = u.User.Password()
+		accrue("password", v)
+	}
+
+	if host, port, err := net.SplitHostPort(u.Host); err != nil {
+		accrue("host", u.Host)
+	} else {
+		accrue("host", host)
+		accrue("port", port)
+	}
+
+	if u.Path != "" {
+		accrue("dbname", u.Path[1:])
+	}
+
+	q := u.Query()
+	for k := range q {
+		accrue(k, q.Get(k))
+	}
+
+	sort.Strings(kvs) // Makes testing easier (not a performance concern)
+	return strings.Join(kvs, " "), nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url_test.go
new file mode 100644
index 0000000..4ff0ce0
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/url_test.go
@@ -0,0 +1,66 @@
+package pq
+
+import (
+	"testing"
+)
+
+func TestSimpleParseURL(t *testing.T) {
+	expected := "host=hostname.remote"
+	str, err := ParseURL("postgres://hostname.remote")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if str != expected {
+		t.Fatalf("unexpected result from ParseURL:\n+ %v\n- %v", str, expected)
+	}
+}
+
+func TestIPv6LoopbackParseURL(t *testing.T) {
+	expected := "host=::1 port=1234"
+	str, err := ParseURL("postgres://[::1]:1234")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if str != expected {
+		t.Fatalf("unexpected result from ParseURL:\n+ %v\n- %v", str, expected)
+	}
+}
+
+func TestFullParseURL(t *testing.T) {
+	expected := `dbname=database host=hostname.remote password=top\ secret port=1234 user=username`
+	str, err := ParseURL("postgres://username:top%20secret@hostname.remote:1234/database")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if str != expected {
+		t.Fatalf("unexpected result from ParseURL:\n+ %s\n- %s", str, expected)
+	}
+}
+
+func TestInvalidProtocolParseURL(t *testing.T) {
+	_, err := ParseURL("http://hostname.remote")
+	switch err {
+	case nil:
+		t.Fatal("Expected an error from parsing invalid protocol")
+	default:
+		msg := "invalid connection protocol: http"
+		if err.Error() != msg {
+			t.Fatalf("Unexpected error message:\n+ %s\n- %s",
+				err.Error(), msg)
+		}
+	}
+}
+
+func TestMinimalURL(t *testing.T) {
+	cs, err := ParseURL("postgres://")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if cs != "" {
+		t.Fatalf("expected blank connection string, got: %q", cs)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_posix.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_posix.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_posix.go
new file mode 100644
index 0000000..bf98252
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_posix.go
@@ -0,0 +1,24 @@
+// Package pq is a pure Go Postgres driver for the database/sql package.
+
+// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris rumprun
+
+package pq
+
+import (
+	"os"
+	"os/user"
+)
+
+func userCurrent() (string, error) {
+	u, err := user.Current()
+	if err == nil {
+		return u.Username, nil
+	}
+
+	name := os.Getenv("USER")
+	if name != "" {
+		return name, nil
+	}
+
+	return "", ErrCouldNotDetectUsername
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_windows.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_windows.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_windows.go
new file mode 100644
index 0000000..2b69126
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/user_windows.go
@@ -0,0 +1,27 @@
+// Package pq is a pure Go Postgres driver for the database/sql package.
+package pq
+
+import (
+	"path/filepath"
+	"syscall"
+)
+
+// Perform Windows user name lookup identically to libpq.
+//
+// The PostgreSQL code makes use of the legacy Win32 function
+// GetUserName, and that function has not been imported into stock Go.
+// GetUserNameEx is available though, the difference being that a
+// wider range of names are available.  To get the output to be the
+// same as GetUserName, only the base (or last) component of the
+// result is returned.
+func userCurrent() (string, error) {
+	pw_name := make([]uint16, 128)
+	pwname_size := uint32(len(pw_name)) - 1
+	err := syscall.GetUserNameEx(syscall.NameSamCompatible, &pw_name[0], &pwname_size)
+	if err != nil {
+		return "", ErrCouldNotDetectUsername
+	}
+	s := syscall.UTF16ToString(pw_name)
+	u := filepath.Base(s)
+	return u, nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid.go
new file mode 100644
index 0000000..9a1b9e0
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid.go
@@ -0,0 +1,23 @@
+package pq
+
+import (
+	"encoding/hex"
+	"fmt"
+)
+
+// decodeUUIDBinary interprets the binary format of a uuid, returning it in text format.
+func decodeUUIDBinary(src []byte) ([]byte, error) {
+	if len(src) != 16 {
+		return nil, fmt.Errorf("pq: unable to decode uuid; bad length: %d", len(src))
+	}
+
+	dst := make([]byte, 36)
+	dst[8], dst[13], dst[18], dst[23] = '-', '-', '-', '-'
+	hex.Encode(dst[0:], src[0:4])
+	hex.Encode(dst[9:], src[4:6])
+	hex.Encode(dst[14:], src[6:8])
+	hex.Encode(dst[19:], src[8:10])
+	hex.Encode(dst[24:], src[10:16])
+
+	return dst, nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid_test.go
new file mode 100644
index 0000000..8ecee2f
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/uuid_test.go
@@ -0,0 +1,46 @@
+package pq
+
+import (
+	"reflect"
+	"strings"
+	"testing"
+)
+
+func TestDecodeUUIDBinaryError(t *testing.T) {
+	t.Parallel()
+	_, err := decodeUUIDBinary([]byte{0x12, 0x34})
+
+	if err == nil {
+		t.Fatal("Expected error, got none")
+	}
+	if !strings.HasPrefix(err.Error(), "pq:") {
+		t.Errorf("Expected error to start with %q, got %q", "pq:", err.Error())
+	}
+	if !strings.Contains(err.Error(), "bad length: 2") {
+		t.Errorf("Expected error to contain length, got %q", err.Error())
+	}
+}
+
+func BenchmarkDecodeUUIDBinary(b *testing.B) {
+	x := []byte{0x03, 0xa3, 0x52, 0x2f, 0x89, 0x28, 0x49, 0x87, 0x84, 0xd6, 0x93, 0x7b, 0x36, 0xec, 0x27, 0x6f}
+
+	for i := 0; i < b.N; i++ {
+		decodeUUIDBinary(x)
+	}
+}
+
+func TestDecodeUUIDBackend(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	var s = "a0ecc91d-a13f-4fe4-9fce-7e09777cc70a"
+	var scanned interface{}
+
+	err := db.QueryRow(`SELECT $1::uuid`, s).Scan(&scanned)
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
+	if !reflect.DeepEqual(scanned, []byte(s)) {
+		t.Errorf("Expected []byte(%q), got %T(%q)", s, scanned, scanned)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/LICENSE
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/LICENSE b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/LICENSE
new file mode 100644
index 0000000..7f8bedf
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/LICENSE
@@ -0,0 +1,28 @@
+The three clause BSD license (http://en.wikipedia.org/wiki/BSD_licenses)
+
+Copyright (c) 2013-2017, DATA-DOG team
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+* The name DataDog.lt may not be used to endorse or promote products
+  derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/README.md
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/README.md b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/README.md
new file mode 100644
index 0000000..f3d5487
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/README.md
@@ -0,0 +1,223 @@
+[![Build Status](https://travis-ci.org/DATA-DOG/go-sqlmock.png)](https://travis-ci.org/DATA-DOG/go-sqlmock)
+[![GoDoc](https://godoc.org/github.com/DATA-DOG/go-sqlmock?status.png)](https://godoc.org/github.com/DATA-DOG/go-sqlmock)
+[![codecov.io](https://codecov.io/github/DATA-DOG/go-sqlmock/branch/master/graph/badge.svg)](https://codecov.io/github/DATA-DOG/go-sqlmock)
+
+# Sql driver mock for Golang
+
+**sqlmock** is a mock library implementing [sql/driver](https://godoc.org/database/sql/driver). Which has one and only
+purpose - to simulate any **sql** driver behavior in tests, without needing a real database connection. It helps to
+maintain correct **TDD** workflow.
+
+- this library is now complete and stable. (you may not find new changes for this reason)
+- supports concurrency and multiple connections.
+- supports **go1.8** Context related feature mocking and Named sql parameters.
+- does not require any modifications to your source code.
+- the driver allows to mock any sql driver method behavior.
+- has strict by default expectation order matching.
+- has no third party dependencies.
+
+## Install
+
+    go get gopkg.in/DATA-DOG/go-sqlmock.v1
+
+## Documentation and Examples
+
+Visit [godoc](http://godoc.org/github.com/DATA-DOG/go-sqlmock) for general examples and public api reference.
+See **.travis.yml** for supported **go** versions.
+Different use case, is to functionally test with a real database - [go-txdb](https://github.com/DATA-DOG/go-txdb)
+all database related actions are isolated within a single transaction so the database can remain in the same state.
+
+See implementation examples:
+
+- [blog API server](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/blog)
+- [the same orders example](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/orders)
+
+### Something you may want to test
+
+``` go
+package main
+
+import "database/sql"
+
+func recordStats(db *sql.DB, userID, productID int64) (err error) {
+	tx, err := db.Begin()
+	if err != nil {
+		return
+	}
+
+	defer func() {
+		switch err {
+		case nil:
+			err = tx.Commit()
+		default:
+			tx.Rollback()
+		}
+	}()
+
+	if _, err = tx.Exec("UPDATE products SET views = views + 1"); err != nil {
+		return
+	}
+	if _, err = tx.Exec("INSERT INTO product_viewers (user_id, product_id) VALUES (?, ?)", userID, productID); err != nil {
+		return
+	}
+	return
+}
+
+func main() {
+	// @NOTE: the real connection is not required for tests
+	db, err := sql.Open("mysql", "root@/blog")
+	if err != nil {
+		panic(err)
+	}
+	defer db.Close()
+
+	if err = recordStats(db, 1 /*some user id*/, 5 /*some product id*/); err != nil {
+		panic(err)
+	}
+}
+```
+
+### Tests with sqlmock
+
+``` go
+package main
+
+import (
+	"fmt"
+	"testing"
+
+	"gopkg.in/DATA-DOG/go-sqlmock.v1"
+)
+
+// a successful case
+func TestShouldUpdateStats(t *testing.T) {
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectBegin()
+	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
+	mock.ExpectExec("INSERT INTO product_viewers").WithArgs(2, 3).WillReturnResult(sqlmock.NewResult(1, 1))
+	mock.ExpectCommit()
+
+	// now we execute our method
+	if err = recordStats(db, 2, 3); err != nil {
+		t.Errorf("error was not expected while updating stats: %s", err)
+	}
+
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+// a failing test case
+func TestShouldRollbackStatUpdatesOnFailure(t *testing.T) {
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectBegin()
+	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
+	mock.ExpectExec("INSERT INTO product_viewers").
+		WithArgs(2, 3).
+		WillReturnError(fmt.Errorf("some error"))
+	mock.ExpectRollback()
+
+	// now we execute our method
+	if err = recordStats(db, 2, 3); err == nil {
+		t.Errorf("was expecting an error, but there was none")
+	}
+
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+```
+
+## Matching arguments like time.Time
+
+There may be arguments which are of `struct` type and cannot be compared easily by value like `time.Time`. In this case
+**sqlmock** provides an [Argument](https://godoc.org/github.com/DATA-DOG/go-sqlmock#Argument) interface which
+can be used in more sophisticated matching. Here is a simple example of time argument matching:
+
+``` go
+type AnyTime struct{}
+
+// Match satisfies sqlmock.Argument interface
+func (a AnyTime) Match(v driver.Value) bool {
+	_, ok := v.(time.Time)
+	return ok
+}
+
+func TestAnyTimeArgument(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectExec("INSERT INTO users").
+		WithArgs("john", AnyTime{}).
+		WillReturnResult(NewResult(1, 1))
+
+	_, err = db.Exec("INSERT INTO users(name, created_at) VALUES (?, ?)", "john", time.Now())
+	if err != nil {
+		t.Errorf("error '%s' was not expected, while inserting a row", err)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+```
+
+It only asserts that argument is of `time.Time` type.
+
+## Run tests
+
+    go test -race
+
+## Change Log
+
+- **2017-02-09** - implemented support for **go1.8** features. **Rows** interface was changed to struct
+  but contains all methods as before and should maintain backwards compatibility. **ExpectedQuery.WillReturnRows** may now
+  accept multiple row sets.
+- **2016-11-02** - `db.Prepare()` was not validating expected prepare SQL
+  query. It should still be validated even if Exec or Query is not
+  executed on that prepared statement.
+- **2016-02-23** - added **sqlmock.AnyArg()** function to provide any kind
+  of argument matcher.
+- **2016-02-23** - convert expected arguments to driver.Value as natural
+  driver does, the change may affect time.Time comparison and will be
+  stricter. See [issue](https://github.com/DATA-DOG/go-sqlmock/issues/31).
+- **2015-08-27** - **v1** api change, concurrency support, all known issues fixed.
+- **2014-08-16** instead of **panic** during reflect type mismatch when comparing query arguments - now return error
+- **2014-08-14** added **sqlmock.NewErrorResult** which gives an option to return driver.Result with errors for
+interface methods, see [issue](https://github.com/DATA-DOG/go-sqlmock/issues/5)
+- **2014-05-29** allow to match arguments in more sophisticated ways, by providing an **sqlmock.Argument** interface
+- **2014-04-21** introduce **sqlmock.New()** to open a mock database connection for tests. This method
+calls sql.DB.Ping to ensure that connection is open, see [issue](https://github.com/DATA-DOG/go-sqlmock/issues/4).
+This way on Close it will surely assert if all expectations are met, even if database was not triggered at all.
+The old way is still available, but it is advisable to call db.Ping manually before asserting with db.Close.
+- **2014-02-14** RowsFromCSVString is now a part of Rows interface named as FromCSVString.
+It has changed to allow more ways to construct rows and to easily extend this API in future.
+See [issue 1](https://github.com/DATA-DOG/go-sqlmock/issues/1)
+**RowsFromCSVString** is deprecated and will be removed in future
+
+## Contributions
+
+Feel free to open a pull request. Note, if you wish to contribute an extension to public (exported methods or types) -
+please open an issue before, to discuss whether these changes can be accepted. All backward incompatible changes are
+and will be treated cautiously
+
+## License
+
+The [three clause BSD license](http://en.wikipedia.org/wiki/BSD_licenses)
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument.go
new file mode 100644
index 0000000..7727481
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument.go
@@ -0,0 +1,24 @@
+package sqlmock
+
+import "database/sql/driver"
+
+// Argument interface allows to match
+// any argument in specific way when used with
+// ExpectedQuery and ExpectedExec expectations.
+type Argument interface {
+	Match(driver.Value) bool
+}
+
+// AnyArg will return an Argument which can
+// match any kind of arguments.
+//
+// Useful for time.Time or similar kinds of arguments.
+func AnyArg() Argument {
+	return anyArgument{}
+}
+
+type anyArgument struct{}
+
+func (a anyArgument) Match(_ driver.Value) bool {
+	return true
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument_test.go
new file mode 100644
index 0000000..3088ed4
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/argument_test.go
@@ -0,0 +1,58 @@
+package sqlmock
+
+import (
+	"database/sql/driver"
+	"testing"
+	"time"
+)
+
+type AnyTime struct{}
+
+// Match satisfies sqlmock.Argument interface
+func (a AnyTime) Match(v driver.Value) bool {
+	_, ok := v.(time.Time)
+	return ok
+}
+
+func TestAnyTimeArgument(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectExec("INSERT INTO users").
+		WithArgs("john", AnyTime{}).
+		WillReturnResult(NewResult(1, 1))
+
+	_, err = db.Exec("INSERT INTO users(name, created_at) VALUES (?, ?)", "john", time.Now())
+	if err != nil {
+		t.Errorf("error '%s' was not expected, while inserting a row", err)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestByteSliceArgument(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	username := []byte("user")
+	mock.ExpectExec("INSERT INTO users").WithArgs(username).WillReturnResult(NewResult(1, 1))
+
+	_, err = db.Exec("INSERT INTO users(username) VALUES (?)", username)
+	if err != nil {
+		t.Errorf("error '%s' was not expected, while inserting a row", err)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver.go
new file mode 100644
index 0000000..2a480fe
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver.go
@@ -0,0 +1,78 @@
+package sqlmock
+
+import (
+	"database/sql"
+	"database/sql/driver"
+	"fmt"
+	"sync"
+)
+
+var pool *mockDriver
+
+func init() {
+	pool = &mockDriver{
+		conns: make(map[string]*sqlmock),
+	}
+	sql.Register("sqlmock", pool)
+}
+
+type mockDriver struct {
+	sync.Mutex
+	counter int
+	conns   map[string]*sqlmock
+}
+
+func (d *mockDriver) Open(dsn string) (driver.Conn, error) {
+	d.Lock()
+	defer d.Unlock()
+
+	c, ok := d.conns[dsn]
+	if !ok {
+		return c, fmt.Errorf("expected a connection to be available, but it is not")
+	}
+
+	c.opened++
+	return c, nil
+}
+
+// New creates sqlmock database connection
+// and a mock to manage expectations.
+// Pings db so that all expectations could be
+// asserted.
+func New() (*sql.DB, Sqlmock, error) {
+	pool.Lock()
+	dsn := fmt.Sprintf("sqlmock_db_%d", pool.counter)
+	pool.counter++
+
+	smock := &sqlmock{dsn: dsn, drv: pool, ordered: true}
+	pool.conns[dsn] = smock
+	pool.Unlock()
+
+	return smock.open()
+}
+
+// NewWithDSN creates sqlmock database connection
+// with a specific DSN and a mock to manage expectations.
+// Pings db so that all expectations could be asserted.
+//
+// This method is introduced because of sql abstraction
+// libraries, which do not provide a way to initialize
+// with sql.DB instance. For example GORM library.
+//
+// Note, it will error if attempted to create with an
+// already used dsn
+//
+// It is not recommended to use this method, unless you
+// really need it and there is no other way around.
+func NewWithDSN(dsn string) (*sql.DB, Sqlmock, error) {
+	pool.Lock()
+	if _, ok := pool.conns[dsn]; ok {
+		pool.Unlock()
+		return nil, nil, fmt.Errorf("cannot create a new mock database with the same dsn: %s", dsn)
+	}
+	smock := &sqlmock{dsn: dsn, drv: pool, ordered: true}
+	pool.conns[dsn] = smock
+	pool.Unlock()
+
+	return smock.open()
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver_test.go
new file mode 100644
index 0000000..1a65c1c
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/driver_test.go
@@ -0,0 +1,112 @@
+package sqlmock
+
+import (
+	"fmt"
+	"testing"
+)
+
+type void struct{}
+
+func (void) Print(...interface{}) {}
+
+func ExampleNew() {
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("expected no error, but got:", err)
+		return
+	}
+	defer db.Close()
+	// now we can expect operations performed on db
+	mock.ExpectBegin().WillReturnError(fmt.Errorf("an error will occur on db.Begin() call"))
+}
+
+func TestShouldOpenConnectionIssue15(t *testing.T) {
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("expected no error, but got: %s", err)
+	}
+	if len(pool.conns) != 1 {
+		t.Errorf("expected 1 connection in pool, but there is: %d", len(pool.conns))
+	}
+
+	smock, _ := mock.(*sqlmock)
+	if smock.opened != 1 {
+		t.Errorf("expected 1 connection on mock to be opened, but there is: %d", smock.opened)
+	}
+
+	// defer so the rows gets closed first
+	defer func() {
+		if smock.opened != 0 {
+			t.Errorf("expected no connections on mock to be opened, but there is: %d", smock.opened)
+		}
+	}()
+
+	mock.ExpectQuery("SELECT").WillReturnRows(NewRows([]string{"one", "two"}).AddRow("val1", "val2"))
+	rows, err := db.Query("SELECT")
+	if err != nil {
+		t.Errorf("unexpected error: %s", err)
+	}
+	defer rows.Close()
+
+	mock.ExpectExec("UPDATE").WillReturnResult(NewResult(1, 1))
+	if _, err = db.Exec("UPDATE"); err != nil {
+		t.Errorf("unexpected error: %s", err)
+	}
+
+	// now there should be two connections open
+	if smock.opened != 2 {
+		t.Errorf("expected 2 connection on mock to be opened, but there is: %d", smock.opened)
+	}
+
+	mock.ExpectClose()
+	if err = db.Close(); err != nil {
+		t.Errorf("expected no error on close, but got: %s", err)
+	}
+
+	// one is still reserved for rows
+	if smock.opened != 1 {
+		t.Errorf("expected 1 connection on mock to be still reserved for rows, but there is: %d", smock.opened)
+	}
+}
+
+func TestTwoOpenConnectionsOnTheSameDSN(t *testing.T) {
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("expected no error, but got: %s", err)
+	}
+	db2, mock2, err := New()
+	if err != nil {
+		t.Errorf("expected no error, but got: %s", err)
+	}
+	if len(pool.conns) != 2 {
+		t.Errorf("expected 2 connection in pool, but there is: %d", len(pool.conns))
+	}
+
+	if db == db2 {
+		t.Errorf("expected not the same database instance, but it is the same")
+	}
+	if mock == mock2 {
+		t.Errorf("expected not the same mock instance, but it is the same")
+	}
+}
+
+func TestWrongDSN(t *testing.T) {
+	t.Parallel()
+	db, _, _ := New()
+	defer db.Close()
+	if _, err := db.Driver().Open("wrong_dsn"); err == nil {
+		t.Error("expected error on Open")
+	}
+}
+
+func TestNewDSN(t *testing.T) {
+	if _, _, err := NewWithDSN("sqlmock_db_99"); err != nil {
+		t.Errorf("expected no error on NewWithDSN, but got: %s", err)
+	}
+}
+
+func TestDuplicateNewDSN(t *testing.T) {
+	if _, _, err := NewWithDSN("sqlmock_db_1"); err == nil {
+		t.Error("expected error on NewWithDSN")
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic.go
new file mode 100644
index 0000000..0fbf98d
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic.go
@@ -0,0 +1,40 @@
+package main
+
+import "database/sql"
+
+func recordStats(db *sql.DB, userID, productID int64) (err error) {
+	tx, err := db.Begin()
+	if err != nil {
+		return
+	}
+
+	defer func() {
+		switch err {
+		case nil:
+			err = tx.Commit()
+		default:
+			tx.Rollback()
+		}
+	}()
+
+	if _, err = tx.Exec("UPDATE products SET views = views + 1"); err != nil {
+		return
+	}
+	if _, err = tx.Exec("INSERT INTO product_viewers (user_id, product_id) VALUES (?, ?)", userID, productID); err != nil {
+		return
+	}
+	return
+}
+
+func main() {
+	// @NOTE: the real connection is not required for tests
+	db, err := sql.Open("mysql", "root@/blog")
+	if err != nil {
+		panic(err)
+	}
+	defer db.Close()
+
+	if err = recordStats(db, 1 /*some user id*/, 5 /*some product id*/); err != nil {
+		panic(err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic_test.go
new file mode 100644
index 0000000..0825f90
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/basic/basic_test.go
@@ -0,0 +1,58 @@
+package main
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/DATA-DOG/go-sqlmock"
+)
+
+// a successful case
+func TestShouldUpdateStats(t *testing.T) {
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectBegin()
+	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
+	mock.ExpectExec("INSERT INTO product_viewers").WithArgs(2, 3).WillReturnResult(sqlmock.NewResult(1, 1))
+	mock.ExpectCommit()
+
+	// now we execute our method
+	if err = recordStats(db, 2, 3); err != nil {
+		t.Errorf("error was not expected while updating stats: %s", err)
+	}
+
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+// a failing test case
+func TestShouldRollbackStatUpdatesOnFailure(t *testing.T) {
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectBegin()
+	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
+	mock.ExpectExec("INSERT INTO product_viewers").
+		WithArgs(2, 3).
+		WillReturnError(fmt.Errorf("some error"))
+	mock.ExpectRollback()
+
+	// now we execute our method
+	if err = recordStats(db, 2, 3); err == nil {
+		t.Errorf("was expecting an error, but there was none")
+	}
+
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog.go
new file mode 100644
index 0000000..c4aec06
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog.go
@@ -0,0 +1,81 @@
+package main
+
+import (
+	"database/sql"
+	"encoding/json"
+	"net/http"
+)
+
+type api struct {
+	db *sql.DB
+}
+
+type post struct {
+	ID    int
+	Title string
+	Body  string
+}
+
+func (a *api) posts(w http.ResponseWriter, r *http.Request) {
+	rows, err := a.db.Query("SELECT id, title, body FROM posts")
+	if err != nil {
+		a.fail(w, "failed to fetch posts: "+err.Error(), 500)
+		return
+	}
+	defer rows.Close()
+
+	var posts []*post
+	for rows.Next() {
+		p := &post{}
+		if err := rows.Scan(&p.ID, &p.Title, &p.Body); err != nil {
+			a.fail(w, "failed to scan post: "+err.Error(), 500)
+			return
+		}
+		posts = append(posts, p)
+	}
+	if rows.Err() != nil {
+		a.fail(w, "failed to read all posts: "+rows.Err().Error(), 500)
+		return
+	}
+
+	data := struct {
+		Posts []*post
+	}{posts}
+
+	a.ok(w, data)
+}
+
+func main() {
+	// @NOTE: the real connection is not required for tests
+	db, err := sql.Open("mysql", "root@/blog")
+	if err != nil {
+		panic(err)
+	}
+	app := &api{db: db}
+	http.HandleFunc("/posts", app.posts)
+	http.ListenAndServe(":8080", nil)
+}
+
+func (a *api) fail(w http.ResponseWriter, msg string, status int) {
+	w.Header().Set("Content-Type", "application/json")
+
+	data := struct {
+		Error string
+	}{Error: msg}
+
+	resp, _ := json.Marshal(data)
+	w.WriteHeader(status)
+	w.Write(resp)
+}
+
+func (a *api) ok(w http.ResponseWriter, data interface{}) {
+	w.Header().Set("Content-Type", "application/json")
+
+	resp, err := json.Marshal(data)
+	if err != nil {
+		w.WriteHeader(http.StatusInternalServerError)
+		a.fail(w, "oops something evil has happened", 500)
+		return
+	}
+	w.Write(resp)
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog_test.go
new file mode 100644
index 0000000..aa1881a
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/blog/blog_test.go
@@ -0,0 +1,102 @@
+package main
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"net/http"
+	"net/http/httptest"
+	"testing"
+
+	"github.com/DATA-DOG/go-sqlmock"
+)
+
+func (a *api) assertJSON(actual []byte, data interface{}, t *testing.T) {
+	expected, err := json.Marshal(data)
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when marshaling expected json data", err)
+	}
+
+	if bytes.Compare(expected, actual) != 0 {
+		t.Errorf("the expected json: %s is different from actual %s", expected, actual)
+	}
+}
+
+func TestShouldGetPosts(t *testing.T) {
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	// create app with mocked db, request and response to test
+	app := &api{db}
+	req, err := http.NewRequest("GET", "http://localhost/posts", nil)
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected while creating request", err)
+	}
+	w := httptest.NewRecorder()
+
+	// before we actually execute our api function, we need to expect required DB actions
+	rows := sqlmock.NewRows([]string{"id", "title", "body"}).
+		AddRow(1, "post 1", "hello").
+		AddRow(2, "post 2", "world")
+
+	mock.ExpectQuery("^SELECT (.+) FROM posts$").WillReturnRows(rows)
+
+	// now we execute our request
+	app.posts(w, req)
+
+	if w.Code != 200 {
+		t.Fatalf("expected status code to be 200, but got: %d", w.Code)
+	}
+
+	data := struct {
+		Posts []*post
+	}{Posts: []*post{
+		{ID: 1, Title: "post 1", Body: "hello"},
+		{ID: 2, Title: "post 2", Body: "world"},
+	}}
+	app.assertJSON(w.Body.Bytes(), data, t)
+
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestShouldRespondWithErrorOnFailure(t *testing.T) {
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	// create app with mocked db, request and response to test
+	app := &api{db}
+	req, err := http.NewRequest("GET", "http://localhost/posts", nil)
+	if err != nil {
+		t.Fatalf("an error '%s' was not expected while creating request", err)
+	}
+	w := httptest.NewRecorder()
+
+	// before we actually execute our api function, we need to expect required DB actions
+	mock.ExpectQuery("^SELECT (.+) FROM posts$").WillReturnError(fmt.Errorf("some error"))
+
+	// now we execute our request
+	app.posts(w, req)
+
+	if w.Code != 500 {
+		t.Fatalf("expected status code to be 500, but got: %d", w.Code)
+	}
+
+	data := struct {
+		Error string
+	}{"failed to fetch posts: some error"}
+	app.assertJSON(w.Body.Bytes(), data, t)
+
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/doc.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/doc.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/doc.go
new file mode 100644
index 0000000..c7842af
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/doc.go
@@ -0,0 +1 @@
+package examples

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders.go
new file mode 100644
index 0000000..fb7e47e
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders.go
@@ -0,0 +1,121 @@
+package main
+
+import (
+	"database/sql"
+	"fmt"
+	"log"
+
+	"github.com/kisielk/sqlstruct"
+)
+
+const ORDER_PENDING = 0
+const ORDER_CANCELLED = 1
+
+type User struct {
+	Id       int     `sql:"id"`
+	Username string  `sql:"username"`
+	Balance  float64 `sql:"balance"`
+}
+
+type Order struct {
+	Id          int     `sql:"id"`
+	Value       float64 `sql:"value"`
+	ReservedFee float64 `sql:"reserved_fee"`
+	Status      int     `sql:"status"`
+}
+
+func cancelOrder(id int, db *sql.DB) (err error) {
+	tx, err := db.Begin()
+	if err != nil {
+		return
+	}
+
+	var order Order
+	var user User
+	sql := fmt.Sprintf(`
+SELECT %s, %s
+FROM orders AS o
+INNER JOIN users AS u ON o.buyer_id = u.id
+WHERE o.id = ?
+FOR UPDATE`,
+		sqlstruct.ColumnsAliased(order, "o"),
+		sqlstruct.ColumnsAliased(user, "u"))
+
+	// fetch order to cancel
+	rows, err := tx.Query(sql, id)
+	if err != nil {
+		tx.Rollback()
+		return
+	}
+
+	defer rows.Close()
+	// no rows, nothing to do
+	if !rows.Next() {
+		tx.Rollback()
+		return
+	}
+
+	// read order
+	err = sqlstruct.ScanAliased(&order, rows, "o")
+	if err != nil {
+		tx.Rollback()
+		return
+	}
+
+	// ensure order status
+	if order.Status != ORDER_PENDING {
+		tx.Rollback()
+		return
+	}
+
+	// read user
+	err = sqlstruct.ScanAliased(&user, rows, "u")
+	if err != nil {
+		tx.Rollback()
+		return
+	}
+	rows.Close() // manually close before other prepared statements
+
+	// refund order value
+	sql = "UPDATE users SET balance = balance + ? WHERE id = ?"
+	refundStmt, err := tx.Prepare(sql)
+	if err != nil {
+		tx.Rollback()
+		return
+	}
+	defer refundStmt.Close()
+	_, err = refundStmt.Exec(order.Value+order.ReservedFee, user.Id)
+	if err != nil {
+		tx.Rollback()
+		return
+	}
+
+	// update order status
+	order.Status = ORDER_CANCELLED
+	sql = "UPDATE orders SET status = ?, updated = NOW() WHERE id = ?"
+	orderUpdStmt, err := tx.Prepare(sql)
+	if err != nil {
+		tx.Rollback()
+		return
+	}
+	defer orderUpdStmt.Close()
+	_, err = orderUpdStmt.Exec(order.Status, order.Id)
+	if err != nil {
+		tx.Rollback()
+		return
+	}
+	return tx.Commit()
+}
+
+func main() {
+	// @NOTE: the real connection is not required for tests
+	db, err := sql.Open("mysql", "root:@/orders")
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer db.Close()
+	err = cancelOrder(1, db)
+	if err != nil {
+		log.Fatal(err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders_test.go
new file mode 100644
index 0000000..7562b8f
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/examples/orders/orders_test.go
@@ -0,0 +1,108 @@
+package main
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/DATA-DOG/go-sqlmock"
+)
+
+// will test that order with a different status, cannot be cancelled
+func TestShouldNotCancelOrderWithNonPendingStatus(t *testing.T) {
+	// open database stub
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Errorf("An error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	// columns are prefixed with "o" since we used sqlstruct to generate them
+	columns := []string{"o_id", "o_status"}
+	// expect transaction begin
+	mock.ExpectBegin()
+	// expect query to fetch order and user, match it with regexp
+	mock.ExpectQuery("SELECT (.+) FROM orders AS o INNER JOIN users AS u (.+) FOR UPDATE").
+		WithArgs(1).
+		WillReturnRows(sqlmock.NewRows(columns).FromCSVString("1,1"))
+	// expect transaction rollback, since order status is "cancelled"
+	mock.ExpectRollback()
+
+	// run the cancel order function
+	err = cancelOrder(1, db)
+	if err != nil {
+		t.Errorf("Expected no error, but got %s instead", err)
+	}
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+// will test order cancellation
+func TestShouldRefundUserWhenOrderIsCancelled(t *testing.T) {
+	// open database stub
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Errorf("An error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	// columns are prefixed with "o" since we used sqlstruct to generate them
+	columns := []string{"o_id", "o_status", "o_value", "o_reserved_fee", "u_id", "u_balance"}
+	// expect transaction begin
+	mock.ExpectBegin()
+	// expect query to fetch order and user, match it with regexp
+	mock.ExpectQuery("SELECT (.+) FROM orders AS o INNER JOIN users AS u (.+) FOR UPDATE").
+		WithArgs(1).
+		WillReturnRows(sqlmock.NewRows(columns).AddRow(1, 0, 25.75, 3.25, 2, 10.00))
+	// expect user balance update
+	mock.ExpectPrepare("UPDATE users SET balance").ExpectExec().
+		WithArgs(25.75+3.25, 2).                  // refund amount, user id
+		WillReturnResult(sqlmock.NewResult(0, 1)) // no insert id, 1 affected row
+	// expect order status update
+	mock.ExpectPrepare("UPDATE orders SET status").ExpectExec().
+		WithArgs(ORDER_CANCELLED, 1).             // status, id
+		WillReturnResult(sqlmock.NewResult(0, 1)) // no insert id, 1 affected row
+	// expect a transaction commit
+	mock.ExpectCommit()
+
+	// run the cancel order function
+	err = cancelOrder(1, db)
+	if err != nil {
+		t.Errorf("Expected no error, but got %s instead", err)
+	}
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+// will test order cancellation
+func TestShouldRollbackOnError(t *testing.T) {
+	// open database stub
+	db, mock, err := sqlmock.New()
+	if err != nil {
+		t.Errorf("An error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	// expect transaction begin
+	mock.ExpectBegin()
+	// expect query to fetch order and user, match it with regexp
+	mock.ExpectQuery("SELECT (.+) FROM orders AS o INNER JOIN users AS u (.+) FOR UPDATE").
+		WithArgs(1).
+		WillReturnError(fmt.Errorf("Some error"))
+	// should rollback since error was returned from query execution
+	mock.ExpectRollback()
+
+	// run the cancel order function
+	err = cancelOrder(1, db)
+	// error should return back
+	if err == nil {
+		t.Error("Expected error, but got none")
+	}
+	// we make sure that all expectations were met
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}


[6/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_test.go
new file mode 100644
index 0000000..d3c01f3
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_test.go
@@ -0,0 +1,1614 @@
+package pq
+
+import (
+	"database/sql"
+	"database/sql/driver"
+	"fmt"
+	"io"
+	"net"
+	"os"
+	"reflect"
+	"strings"
+	"testing"
+	"time"
+)
+
+type Fatalistic interface {
+	Fatal(args ...interface{})
+}
+
+func forceBinaryParameters() bool {
+	bp := os.Getenv("PQTEST_BINARY_PARAMETERS")
+	if bp == "yes" {
+		return true
+	} else if bp == "" || bp == "no" {
+		return false
+	} else {
+		panic("unexpected value for PQTEST_BINARY_PARAMETERS")
+	}
+}
+
+func openTestConnConninfo(conninfo string) (*sql.DB, error) {
+	defaultTo := func(envvar string, value string) {
+		if os.Getenv(envvar) == "" {
+			os.Setenv(envvar, value)
+		}
+	}
+	defaultTo("PGDATABASE", "pqgotest")
+	defaultTo("PGSSLMODE", "disable")
+	defaultTo("PGCONNECT_TIMEOUT", "20")
+
+	if forceBinaryParameters() &&
+		!strings.HasPrefix(conninfo, "postgres://") &&
+		!strings.HasPrefix(conninfo, "postgresql://") {
+		conninfo = conninfo + " binary_parameters=yes"
+	}
+
+	return sql.Open("postgres", conninfo)
+}
+
+func openTestConn(t Fatalistic) *sql.DB {
+	conn, err := openTestConnConninfo("")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	return conn
+}
+
+func getServerVersion(t *testing.T, db *sql.DB) int {
+	var version int
+	err := db.QueryRow("SHOW server_version_num").Scan(&version)
+	if err != nil {
+		t.Fatal(err)
+	}
+	return version
+}
+
+func TestReconnect(t *testing.T) {
+	db1 := openTestConn(t)
+	defer db1.Close()
+	tx, err := db1.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	var pid1 int
+	err = tx.QueryRow("SELECT pg_backend_pid()").Scan(&pid1)
+	if err != nil {
+		t.Fatal(err)
+	}
+	db2 := openTestConn(t)
+	defer db2.Close()
+	_, err = db2.Exec("SELECT pg_terminate_backend($1)", pid1)
+	if err != nil {
+		t.Fatal(err)
+	}
+	// The rollback will probably "fail" because we just killed
+	// its connection above
+	_ = tx.Rollback()
+
+	const expected int = 42
+	var result int
+	err = db1.QueryRow(fmt.Sprintf("SELECT %d", expected)).Scan(&result)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if result != expected {
+		t.Errorf("got %v; expected %v", result, expected)
+	}
+}
+
+func TestCommitInFailedTransaction(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows, err := txn.Query("SELECT error")
+	if err == nil {
+		rows.Close()
+		t.Fatal("expected failure")
+	}
+	err = txn.Commit()
+	if err != ErrInFailedTransaction {
+		t.Fatalf("expected ErrInFailedTransaction; got %#v", err)
+	}
+}
+
+func TestOpenURL(t *testing.T) {
+	testURL := func(url string) {
+		db, err := openTestConnConninfo(url)
+		if err != nil {
+			t.Fatal(err)
+		}
+		defer db.Close()
+		// database/sql might not call our Open at all unless we do something with
+		// the connection
+		txn, err := db.Begin()
+		if err != nil {
+			t.Fatal(err)
+		}
+		txn.Rollback()
+	}
+	testURL("postgres://")
+	testURL("postgresql://")
+}
+
+const pgpassFile = "/tmp/pqgotest_pgpass"
+
+func TestPgpass(t *testing.T) {
+	if os.Getenv("TRAVIS") != "true" {
+		t.Skip("not running under Travis, skipping pgpass tests")
+	}
+
+	testAssert := func(conninfo string, expected string, reason string) {
+		conn, err := openTestConnConninfo(conninfo)
+		if err != nil {
+			t.Fatal(err)
+		}
+		defer conn.Close()
+
+		txn, err := conn.Begin()
+		if err != nil {
+			if expected != "fail" {
+				t.Fatalf(reason, err)
+			}
+			return
+		}
+		rows, err := txn.Query("SELECT USER")
+		if err != nil {
+			txn.Rollback()
+			if expected != "fail" {
+				t.Fatalf(reason, err)
+			}
+		} else {
+			rows.Close()
+			if expected != "ok" {
+				t.Fatalf(reason, err)
+			}
+		}
+		txn.Rollback()
+	}
+	testAssert("", "ok", "missing .pgpass, unexpected error %#v")
+	os.Setenv("PGPASSFILE", pgpassFile)
+	testAssert("host=/tmp", "fail", ", unexpected error %#v")
+	os.Remove(pgpassFile)
+	pgpass, err := os.OpenFile(pgpassFile, os.O_RDWR|os.O_CREATE, 0644)
+	if err != nil {
+		t.Fatalf("Unexpected error writing pgpass file %#v", err)
+	}
+	_, err = pgpass.WriteString(`# comment
+server:5432:some_db:some_user:pass_A
+*:5432:some_db:some_user:pass_B
+localhost:*:*:*:pass_C
+*:*:*:*:pass_fallback
+`)
+	if err != nil {
+		t.Fatalf("Unexpected error writing pgpass file %#v", err)
+	}
+	pgpass.Close()
+
+	assertPassword := func(extra values, expected string) {
+		o := values{
+			"host":               "localhost",
+			"sslmode":            "disable",
+			"connect_timeout":    "20",
+			"user":               "majid",
+			"port":               "5432",
+			"extra_float_digits": "2",
+			"dbname":             "pqgotest",
+			"client_encoding":    "UTF8",
+			"datestyle":          "ISO, MDY",
+		}
+		for k, v := range extra {
+			o[k] = v
+		}
+		(&conn{}).handlePgpass(o)
+		if pw := o["password"]; pw != expected {
+			t.Fatalf("For %v expected %s got %s", extra, expected, pw)
+		}
+	}
+	// wrong permissions for the pgpass file means it should be ignored
+	assertPassword(values{"host": "example.com", "user": "foo"}, "")
+	// fix the permissions and check if it has taken effect
+	os.Chmod(pgpassFile, 0600)
+	assertPassword(values{"host": "server", "dbname": "some_db", "user": "some_user"}, "pass_A")
+	assertPassword(values{"host": "example.com", "user": "foo"}, "pass_fallback")
+	assertPassword(values{"host": "example.com", "dbname": "some_db", "user": "some_user"}, "pass_B")
+	// localhost also matches the default "" and UNIX sockets
+	assertPassword(values{"host": "", "user": "some_user"}, "pass_C")
+	assertPassword(values{"host": "/tmp", "user": "some_user"}, "pass_C")
+	// cleanup
+	os.Remove(pgpassFile)
+	os.Setenv("PGPASSFILE", "")
+}
+
+func TestExec(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	_, err := db.Exec("CREATE TEMP TABLE temp (a int)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	r, err := db.Exec("INSERT INTO temp VALUES (1)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if n, _ := r.RowsAffected(); n != 1 {
+		t.Fatalf("expected 1 row affected, not %d", n)
+	}
+
+	r, err = db.Exec("INSERT INTO temp VALUES ($1), ($2), ($3)", 1, 2, 3)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if n, _ := r.RowsAffected(); n != 3 {
+		t.Fatalf("expected 3 rows affected, not %d", n)
+	}
+
+	// SELECT doesn't send the number of returned rows in the command tag
+	// before 9.0
+	if getServerVersion(t, db) >= 90000 {
+		r, err = db.Exec("SELECT g FROM generate_series(1, 2) g")
+		if err != nil {
+			t.Fatal(err)
+		}
+		if n, _ := r.RowsAffected(); n != 2 {
+			t.Fatalf("expected 2 rows affected, not %d", n)
+		}
+
+		r, err = db.Exec("SELECT g FROM generate_series(1, $1) g", 3)
+		if err != nil {
+			t.Fatal(err)
+		}
+		if n, _ := r.RowsAffected(); n != 3 {
+			t.Fatalf("expected 3 rows affected, not %d", n)
+		}
+	}
+}
+
+func TestStatment(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	st, err := db.Prepare("SELECT 1")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	st1, err := db.Prepare("SELECT 2")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	r, err := st.Query()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer r.Close()
+
+	if !r.Next() {
+		t.Fatal("expected row")
+	}
+
+	var i int
+	err = r.Scan(&i)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if i != 1 {
+		t.Fatalf("expected 1, got %d", i)
+	}
+
+	// st1
+
+	r1, err := st1.Query()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer r1.Close()
+
+	if !r1.Next() {
+		if r.Err() != nil {
+			t.Fatal(r1.Err())
+		}
+		t.Fatal("expected row")
+	}
+
+	err = r1.Scan(&i)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if i != 2 {
+		t.Fatalf("expected 2, got %d", i)
+	}
+}
+
+func TestRowsCloseBeforeDone(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	r, err := db.Query("SELECT 1")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = r.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if r.Next() {
+		t.Fatal("unexpected row")
+	}
+
+	if r.Err() != nil {
+		t.Fatal(r.Err())
+	}
+}
+
+func TestParameterCountMismatch(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	var notused int
+	err := db.QueryRow("SELECT false", 1).Scan(&notused)
+	if err == nil {
+		t.Fatal("expected err")
+	}
+	// make sure we clean up correctly
+	err = db.QueryRow("SELECT 1").Scan(&notused)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = db.QueryRow("SELECT $1").Scan(&notused)
+	if err == nil {
+		t.Fatal("expected err")
+	}
+	// make sure we clean up correctly
+	err = db.QueryRow("SELECT 1").Scan(&notused)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+// Test that EmptyQueryResponses are handled correctly.
+func TestEmptyQuery(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	res, err := db.Exec("")
+	if err != nil {
+		t.Fatal(err)
+	}
+	if _, err := res.RowsAffected(); err != errNoRowsAffected {
+		t.Fatalf("expected %s, got %v", errNoRowsAffected, err)
+	}
+	if _, err := res.LastInsertId(); err != errNoLastInsertID {
+		t.Fatalf("expected %s, got %v", errNoLastInsertID, err)
+	}
+	rows, err := db.Query("")
+	if err != nil {
+		t.Fatal(err)
+	}
+	cols, err := rows.Columns()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if len(cols) != 0 {
+		t.Fatalf("unexpected number of columns %d in response to an empty query", len(cols))
+	}
+	if rows.Next() {
+		t.Fatal("unexpected row")
+	}
+	if rows.Err() != nil {
+		t.Fatal(rows.Err())
+	}
+
+	stmt, err := db.Prepare("")
+	if err != nil {
+		t.Fatal(err)
+	}
+	res, err = stmt.Exec()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if _, err := res.RowsAffected(); err != errNoRowsAffected {
+		t.Fatalf("expected %s, got %v", errNoRowsAffected, err)
+	}
+	if _, err := res.LastInsertId(); err != errNoLastInsertID {
+		t.Fatalf("expected %s, got %v", errNoLastInsertID, err)
+	}
+	rows, err = stmt.Query()
+	if err != nil {
+		t.Fatal(err)
+	}
+	cols, err = rows.Columns()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if len(cols) != 0 {
+		t.Fatalf("unexpected number of columns %d in response to an empty query", len(cols))
+	}
+	if rows.Next() {
+		t.Fatal("unexpected row")
+	}
+	if rows.Err() != nil {
+		t.Fatal(rows.Err())
+	}
+}
+
+// Test that rows.Columns() is correct even if there are no result rows.
+func TestEmptyResultSetColumns(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	rows, err := db.Query("SELECT 1 AS a, text 'bar' AS bar WHERE FALSE")
+	if err != nil {
+		t.Fatal(err)
+	}
+	cols, err := rows.Columns()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if len(cols) != 2 {
+		t.Fatalf("unexpected number of columns %d in response to an empty query", len(cols))
+	}
+	if rows.Next() {
+		t.Fatal("unexpected row")
+	}
+	if rows.Err() != nil {
+		t.Fatal(rows.Err())
+	}
+	if cols[0] != "a" || cols[1] != "bar" {
+		t.Fatalf("unexpected Columns result %v", cols)
+	}
+
+	stmt, err := db.Prepare("SELECT $1::int AS a, text 'bar' AS bar WHERE FALSE")
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows, err = stmt.Query(1)
+	if err != nil {
+		t.Fatal(err)
+	}
+	cols, err = rows.Columns()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if len(cols) != 2 {
+		t.Fatalf("unexpected number of columns %d in response to an empty query", len(cols))
+	}
+	if rows.Next() {
+		t.Fatal("unexpected row")
+	}
+	if rows.Err() != nil {
+		t.Fatal(rows.Err())
+	}
+	if cols[0] != "a" || cols[1] != "bar" {
+		t.Fatalf("unexpected Columns result %v", cols)
+	}
+
+}
+
+func TestEncodeDecode(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	q := `
+		SELECT
+			E'\\000\\001\\002'::bytea,
+			'foobar'::text,
+			NULL::integer,
+			'2000-1-1 01:02:03.04-7'::timestamptz,
+			0::boolean,
+			123,
+			-321,
+			3.14::float8
+		WHERE
+			    E'\\000\\001\\002'::bytea = $1
+			AND 'foobar'::text = $2
+			AND $3::integer is NULL
+	`
+	// AND '2000-1-1 12:00:00.000000-7'::timestamp = $3
+
+	exp1 := []byte{0, 1, 2}
+	exp2 := "foobar"
+
+	r, err := db.Query(q, exp1, exp2, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer r.Close()
+
+	if !r.Next() {
+		if r.Err() != nil {
+			t.Fatal(r.Err())
+		}
+		t.Fatal("expected row")
+	}
+
+	var got1 []byte
+	var got2 string
+	var got3 = sql.NullInt64{Valid: true}
+	var got4 time.Time
+	var got5, got6, got7, got8 interface{}
+
+	err = r.Scan(&got1, &got2, &got3, &got4, &got5, &got6, &got7, &got8)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if !reflect.DeepEqual(exp1, got1) {
+		t.Errorf("expected %q byte: %q", exp1, got1)
+	}
+
+	if !reflect.DeepEqual(exp2, got2) {
+		t.Errorf("expected %q byte: %q", exp2, got2)
+	}
+
+	if got3.Valid {
+		t.Fatal("expected invalid")
+	}
+
+	if got4.Year() != 2000 {
+		t.Fatal("wrong year")
+	}
+
+	if got5 != false {
+		t.Fatalf("expected false, got %q", got5)
+	}
+
+	if got6 != int64(123) {
+		t.Fatalf("expected 123, got %d", got6)
+	}
+
+	if got7 != int64(-321) {
+		t.Fatalf("expected -321, got %d", got7)
+	}
+
+	if got8 != float64(3.14) {
+		t.Fatalf("expected 3.14, got %f", got8)
+	}
+}
+
+func TestNoData(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	st, err := db.Prepare("SELECT 1 WHERE true = false")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer st.Close()
+
+	r, err := st.Query()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer r.Close()
+
+	if r.Next() {
+		if r.Err() != nil {
+			t.Fatal(r.Err())
+		}
+		t.Fatal("unexpected row")
+	}
+
+	_, err = db.Query("SELECT * FROM nonexistenttable WHERE age=$1", 20)
+	if err == nil {
+		t.Fatal("Should have raised an error on non existent table")
+	}
+
+	_, err = db.Query("SELECT * FROM nonexistenttable")
+	if err == nil {
+		t.Fatal("Should have raised an error on non existent table")
+	}
+}
+
+func TestErrorDuringStartup(t *testing.T) {
+	// Don't use the normal connection setup, this is intended to
+	// blow up in the startup packet from a non-existent user.
+	db, err := openTestConnConninfo("user=thisuserreallydoesntexist")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer db.Close()
+
+	_, err = db.Begin()
+	if err == nil {
+		t.Fatal("expected error")
+	}
+
+	e, ok := err.(*Error)
+	if !ok {
+		t.Fatalf("expected Error, got %#v", err)
+	} else if e.Code.Name() != "invalid_authorization_specification" && e.Code.Name() != "invalid_password" {
+		t.Fatalf("expected invalid_authorization_specification or invalid_password, got %s (%+v)", e.Code.Name(), err)
+	}
+}
+
+func TestBadConn(t *testing.T) {
+	var err error
+
+	cn := conn{}
+	func() {
+		defer cn.errRecover(&err)
+		panic(io.EOF)
+	}()
+	if err != driver.ErrBadConn {
+		t.Fatalf("expected driver.ErrBadConn, got: %#v", err)
+	}
+	if !cn.bad {
+		t.Fatalf("expected cn.bad")
+	}
+
+	cn = conn{}
+	func() {
+		defer cn.errRecover(&err)
+		e := &Error{Severity: Efatal}
+		panic(e)
+	}()
+	if err != driver.ErrBadConn {
+		t.Fatalf("expected driver.ErrBadConn, got: %#v", err)
+	}
+	if !cn.bad {
+		t.Fatalf("expected cn.bad")
+	}
+}
+
+// TestCloseBadConn tests that the underlying connection can be closed with
+// Close after an error.
+func TestCloseBadConn(t *testing.T) {
+	nc, err := net.Dial("tcp", "localhost:5432")
+	if err != nil {
+		t.Fatal(err)
+	}
+	cn := conn{c: nc}
+	func() {
+		defer cn.errRecover(&err)
+		panic(io.EOF)
+	}()
+	// Verify we can write before closing.
+	if _, err := nc.Write(nil); err != nil {
+		t.Fatal(err)
+	}
+	// First close should close the connection.
+	if err := cn.Close(); err != nil {
+		t.Fatal(err)
+	}
+
+	// During the Go 1.9 cycle, https://github.com/golang/go/commit/3792db5
+	// changed this error from
+	//
+	// net.errClosing = errors.New("use of closed network connection")
+	//
+	// to
+	//
+	// internal/poll.ErrClosing = errors.New("use of closed file or network connection")
+	const errClosing = "use of closed"
+
+	// Verify write after closing fails.
+	if _, err := nc.Write(nil); err == nil {
+		t.Fatal("expected error")
+	} else if !strings.Contains(err.Error(), errClosing) {
+		t.Fatalf("expected %s error, got %s", errClosing, err)
+	}
+	// Verify second close fails.
+	if err := cn.Close(); err == nil {
+		t.Fatal("expected error")
+	} else if !strings.Contains(err.Error(), errClosing) {
+		t.Fatalf("expected %s error, got %s", errClosing, err)
+	}
+}
+
+func TestErrorOnExec(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMPORARY TABLE foo(f1 int PRIMARY KEY)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = txn.Exec("INSERT INTO foo VALUES (0), (0)")
+	if err == nil {
+		t.Fatal("Should have raised error")
+	}
+
+	e, ok := err.(*Error)
+	if !ok {
+		t.Fatalf("expected Error, got %#v", err)
+	} else if e.Code.Name() != "unique_violation" {
+		t.Fatalf("expected unique_violation, got %s (%+v)", e.Code.Name(), err)
+	}
+}
+
+func TestErrorOnQuery(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMPORARY TABLE foo(f1 int PRIMARY KEY)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = txn.Query("INSERT INTO foo VALUES (0), (0)")
+	if err == nil {
+		t.Fatal("Should have raised error")
+	}
+
+	e, ok := err.(*Error)
+	if !ok {
+		t.Fatalf("expected Error, got %#v", err)
+	} else if e.Code.Name() != "unique_violation" {
+		t.Fatalf("expected unique_violation, got %s (%+v)", e.Code.Name(), err)
+	}
+}
+
+func TestErrorOnQueryRowSimpleQuery(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMPORARY TABLE foo(f1 int PRIMARY KEY)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var v int
+	err = txn.QueryRow("INSERT INTO foo VALUES (0), (0)").Scan(&v)
+	if err == nil {
+		t.Fatal("Should have raised error")
+	}
+
+	e, ok := err.(*Error)
+	if !ok {
+		t.Fatalf("expected Error, got %#v", err)
+	} else if e.Code.Name() != "unique_violation" {
+		t.Fatalf("expected unique_violation, got %s (%+v)", e.Code.Name(), err)
+	}
+}
+
+// Test the QueryRow bug workarounds in stmt.exec() and simpleQuery()
+func TestQueryRowBugWorkaround(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	// stmt.exec()
+	_, err := db.Exec("CREATE TEMP TABLE notnulltemp (a varchar(10) not null)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var a string
+	err = db.QueryRow("INSERT INTO notnulltemp(a) values($1) RETURNING a", nil).Scan(&a)
+	if err == sql.ErrNoRows {
+		t.Fatalf("expected constraint violation error; got: %v", err)
+	}
+	pge, ok := err.(*Error)
+	if !ok {
+		t.Fatalf("expected *Error; got: %#v", err)
+	}
+	if pge.Code.Name() != "not_null_violation" {
+		t.Fatalf("expected not_null_violation; got: %s (%+v)", pge.Code.Name(), err)
+	}
+
+	// Test workaround in simpleQuery()
+	tx, err := db.Begin()
+	if err != nil {
+		t.Fatalf("unexpected error %s in Begin", err)
+	}
+	defer tx.Rollback()
+
+	_, err = tx.Exec("SET LOCAL check_function_bodies TO FALSE")
+	if err != nil {
+		t.Fatalf("could not disable check_function_bodies: %s", err)
+	}
+	_, err = tx.Exec(`
+CREATE OR REPLACE FUNCTION bad_function()
+RETURNS integer
+-- hack to prevent the function from being inlined
+SET check_function_bodies TO TRUE
+AS $$
+	SELECT text 'bad'
+$$ LANGUAGE sql`)
+	if err != nil {
+		t.Fatalf("could not create function: %s", err)
+	}
+
+	err = tx.QueryRow("SELECT * FROM bad_function()").Scan(&a)
+	if err == nil {
+		t.Fatalf("expected error")
+	}
+	pge, ok = err.(*Error)
+	if !ok {
+		t.Fatalf("expected *Error; got: %#v", err)
+	}
+	if pge.Code.Name() != "invalid_function_definition" {
+		t.Fatalf("expected invalid_function_definition; got: %s (%+v)", pge.Code.Name(), err)
+	}
+
+	err = tx.Rollback()
+	if err != nil {
+		t.Fatalf("unexpected error %s in Rollback", err)
+	}
+
+	// Also test that simpleQuery()'s workaround works when the query fails
+	// after a row has been received.
+	rows, err := db.Query(`
+select
+	(select generate_series(1, ss.i))
+from (select gs.i
+      from generate_series(1, 2) gs(i)
+      order by gs.i limit 2) ss`)
+	if err != nil {
+		t.Fatalf("query failed: %s", err)
+	}
+	if !rows.Next() {
+		t.Fatalf("expected at least one result row; got %s", rows.Err())
+	}
+	var i int
+	err = rows.Scan(&i)
+	if err != nil {
+		t.Fatalf("rows.Scan() failed: %s", err)
+	}
+	if i != 1 {
+		t.Fatalf("unexpected value for i: %d", i)
+	}
+	if rows.Next() {
+		t.Fatalf("unexpected row")
+	}
+	pge, ok = rows.Err().(*Error)
+	if !ok {
+		t.Fatalf("expected *Error; got: %#v", err)
+	}
+	if pge.Code.Name() != "cardinality_violation" {
+		t.Fatalf("expected cardinality_violation; got: %s (%+v)", pge.Code.Name(), rows.Err())
+	}
+}
+
+func TestSimpleQuery(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	r, err := db.Query("select 1")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer r.Close()
+
+	if !r.Next() {
+		t.Fatal("expected row")
+	}
+}
+
+func TestBindError(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	_, err := db.Exec("create temp table test (i integer)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Query("select * from test where i=$1", "hhh")
+	if err == nil {
+		t.Fatal("expected an error")
+	}
+
+	// Should not get error here
+	r, err := db.Query("select * from test where i=$1", 1)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer r.Close()
+}
+
+func TestParseErrorInExtendedQuery(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	rows, err := db.Query("PARSE_ERROR $1", 1)
+	if err == nil {
+		t.Fatal("expected error")
+	}
+
+	rows, err = db.Query("SELECT 1")
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows.Close()
+}
+
+// TestReturning tests that an INSERT query using the RETURNING clause returns a row.
+func TestReturning(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	_, err := db.Exec("CREATE TEMP TABLE distributors (did integer default 0, dname text)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	rows, err := db.Query("INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets') " +
+		"RETURNING did;")
+	if err != nil {
+		t.Fatal(err)
+	}
+	if !rows.Next() {
+		t.Fatal("no rows")
+	}
+	var did int
+	err = rows.Scan(&did)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if did != 0 {
+		t.Fatalf("bad value for did: got %d, want %d", did, 0)
+	}
+
+	if rows.Next() {
+		t.Fatal("unexpected next row")
+	}
+	err = rows.Err()
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestIssue186(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	// Exec() a query which returns results
+	_, err := db.Exec("VALUES (1), (2), (3)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = db.Exec("VALUES ($1), ($2), ($3)", 1, 2, 3)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	// Query() a query which doesn't return any results
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	rows, err := txn.Query("CREATE TEMP TABLE foo(f1 int)")
+	if err != nil {
+		t.Fatal(err)
+	}
+	if err = rows.Close(); err != nil {
+		t.Fatal(err)
+	}
+
+	// small trick to get NoData from a parameterized query
+	_, err = txn.Exec("CREATE RULE nodata AS ON INSERT TO foo DO INSTEAD NOTHING")
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows, err = txn.Query("INSERT INTO foo VALUES ($1)", 1)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if err = rows.Close(); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestIssue196(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	row := db.QueryRow("SELECT float4 '0.10000122' = $1, float8 '35.03554004971999' = $2",
+		float32(0.10000122), float64(35.03554004971999))
+
+	var float4match, float8match bool
+	err := row.Scan(&float4match, &float8match)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if !float4match {
+		t.Errorf("Expected float4 fidelity to be maintained; got no match")
+	}
+	if !float8match {
+		t.Errorf("Expected float8 fidelity to be maintained; got no match")
+	}
+}
+
+// Test that any CommandComplete messages sent before the query results are
+// ignored.
+func TestIssue282(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	var searchPath string
+	err := db.QueryRow(`
+		SET LOCAL search_path TO pg_catalog;
+		SET LOCAL search_path TO pg_catalog;
+		SHOW search_path`).Scan(&searchPath)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if searchPath != "pg_catalog" {
+		t.Fatalf("unexpected search_path %s", searchPath)
+	}
+}
+
+func TestReadFloatPrecision(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	row := db.QueryRow("SELECT float4 '0.10000122', float8 '35.03554004971999'")
+	var float4val float32
+	var float8val float64
+	err := row.Scan(&float4val, &float8val)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if float4val != float32(0.10000122) {
+		t.Errorf("Expected float4 fidelity to be maintained; got no match")
+	}
+	if float8val != float64(35.03554004971999) {
+		t.Errorf("Expected float8 fidelity to be maintained; got no match")
+	}
+}
+
+func TestXactMultiStmt(t *testing.T) {
+	// minified test case based on bug reports from
+	// pico303@gmail.com and rangelspam@gmail.com
+	t.Skip("Skipping failing test")
+	db := openTestConn(t)
+	defer db.Close()
+
+	tx, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer tx.Commit()
+
+	rows, err := tx.Query("select 1")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if rows.Next() {
+		var val int32
+		if err = rows.Scan(&val); err != nil {
+			t.Fatal(err)
+		}
+	} else {
+		t.Fatal("Expected at least one row in first query in xact")
+	}
+
+	rows2, err := tx.Query("select 2")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if rows2.Next() {
+		var val2 int32
+		if err := rows2.Scan(&val2); err != nil {
+			t.Fatal(err)
+		}
+	} else {
+		t.Fatal("Expected at least one row in second query in xact")
+	}
+
+	if err = rows.Err(); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = rows2.Err(); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = tx.Commit(); err != nil {
+		t.Fatal(err)
+	}
+}
+
+var envParseTests = []struct {
+	Expected map[string]string
+	Env      []string
+}{
+	{
+		Env:      []string{"PGDATABASE=hello", "PGUSER=goodbye"},
+		Expected: map[string]string{"dbname": "hello", "user": "goodbye"},
+	},
+	{
+		Env:      []string{"PGDATESTYLE=ISO, MDY"},
+		Expected: map[string]string{"datestyle": "ISO, MDY"},
+	},
+	{
+		Env:      []string{"PGCONNECT_TIMEOUT=30"},
+		Expected: map[string]string{"connect_timeout": "30"},
+	},
+}
+
+func TestParseEnviron(t *testing.T) {
+	for i, tt := range envParseTests {
+		results := parseEnviron(tt.Env)
+		if !reflect.DeepEqual(tt.Expected, results) {
+			t.Errorf("%d: Expected: %#v Got: %#v", i, tt.Expected, results)
+		}
+	}
+}
+
+func TestParseComplete(t *testing.T) {
+	tpc := func(commandTag string, command string, affectedRows int64, shouldFail bool) {
+		defer func() {
+			if p := recover(); p != nil {
+				if !shouldFail {
+					t.Error(p)
+				}
+			}
+		}()
+		cn := &conn{}
+		res, c := cn.parseComplete(commandTag)
+		if c != command {
+			t.Errorf("Expected %v, got %v", command, c)
+		}
+		n, err := res.RowsAffected()
+		if err != nil {
+			t.Fatal(err)
+		}
+		if n != affectedRows {
+			t.Errorf("Expected %d, got %d", affectedRows, n)
+		}
+	}
+
+	tpc("ALTER TABLE", "ALTER TABLE", 0, false)
+	tpc("INSERT 0 1", "INSERT", 1, false)
+	tpc("UPDATE 100", "UPDATE", 100, false)
+	tpc("SELECT 100", "SELECT", 100, false)
+	tpc("FETCH 100", "FETCH", 100, false)
+	// allow COPY (and others) without row count
+	tpc("COPY", "COPY", 0, false)
+	// don't fail on command tags we don't recognize
+	tpc("UNKNOWNCOMMANDTAG", "UNKNOWNCOMMANDTAG", 0, false)
+
+	// failure cases
+	tpc("INSERT 1", "", 0, true)   // missing oid
+	tpc("UPDATE 0 1", "", 0, true) // too many numbers
+	tpc("SELECT foo", "", 0, true) // invalid row count
+}
+
+func TestExecerInterface(t *testing.T) {
+	// Gin up a straw man private struct just for the type check
+	cn := &conn{c: nil}
+	var cni interface{} = cn
+
+	_, ok := cni.(driver.Execer)
+	if !ok {
+		t.Fatal("Driver doesn't implement Execer")
+	}
+}
+
+func TestNullAfterNonNull(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	r, err := db.Query("SELECT 9::integer UNION SELECT NULL::integer")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var n sql.NullInt64
+
+	if !r.Next() {
+		if r.Err() != nil {
+			t.Fatal(err)
+		}
+		t.Fatal("expected row")
+	}
+
+	if err := r.Scan(&n); err != nil {
+		t.Fatal(err)
+	}
+
+	if n.Int64 != 9 {
+		t.Fatalf("expected 2, not %d", n.Int64)
+	}
+
+	if !r.Next() {
+		if r.Err() != nil {
+			t.Fatal(err)
+		}
+		t.Fatal("expected row")
+	}
+
+	if err := r.Scan(&n); err != nil {
+		t.Fatal(err)
+	}
+
+	if n.Valid {
+		t.Fatal("expected n to be invalid")
+	}
+
+	if n.Int64 != 0 {
+		t.Fatalf("expected n to 2, not %d", n.Int64)
+	}
+}
+
+func Test64BitErrorChecking(t *testing.T) {
+	defer func() {
+		if err := recover(); err != nil {
+			t.Fatal("panic due to 0xFFFFFFFF != -1 " +
+				"when int is 64 bits")
+		}
+	}()
+
+	db := openTestConn(t)
+	defer db.Close()
+
+	r, err := db.Query(`SELECT *
+FROM (VALUES (0::integer, NULL::text), (1, 'test string')) AS t;`)
+
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	defer r.Close()
+
+	for r.Next() {
+	}
+}
+
+func TestCommit(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	_, err := db.Exec("CREATE TEMP TABLE temp (a int)")
+	if err != nil {
+		t.Fatal(err)
+	}
+	sqlInsert := "INSERT INTO temp VALUES (1)"
+	sqlSelect := "SELECT * FROM temp"
+	tx, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	_, err = tx.Exec(sqlInsert)
+	if err != nil {
+		t.Fatal(err)
+	}
+	err = tx.Commit()
+	if err != nil {
+		t.Fatal(err)
+	}
+	var i int
+	err = db.QueryRow(sqlSelect).Scan(&i)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if i != 1 {
+		t.Fatalf("expected 1, got %d", i)
+	}
+}
+
+func TestErrorClass(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	_, err := db.Query("SELECT int 'notint'")
+	if err == nil {
+		t.Fatal("expected error")
+	}
+	pge, ok := err.(*Error)
+	if !ok {
+		t.Fatalf("expected *pq.Error, got %#+v", err)
+	}
+	if pge.Code.Class() != "22" {
+		t.Fatalf("expected class 28, got %v", pge.Code.Class())
+	}
+	if pge.Code.Class().Name() != "data_exception" {
+		t.Fatalf("expected data_exception, got %v", pge.Code.Class().Name())
+	}
+}
+
+func TestParseOpts(t *testing.T) {
+	tests := []struct {
+		in       string
+		expected values
+		valid    bool
+	}{
+		{"dbname=hello user=goodbye", values{"dbname": "hello", "user": "goodbye"}, true},
+		{"dbname=hello user=goodbye  ", values{"dbname": "hello", "user": "goodbye"}, true},
+		{"dbname = hello user=goodbye", values{"dbname": "hello", "user": "goodbye"}, true},
+		{"dbname=hello user =goodbye", values{"dbname": "hello", "user": "goodbye"}, true},
+		{"dbname=hello user= goodbye", values{"dbname": "hello", "user": "goodbye"}, true},
+		{"host=localhost password='correct horse battery staple'", values{"host": "localhost", "password": "correct horse battery staple"}, true},
+		{"dbname=データベース password=パスワード", values{"dbname": "データベース", "password": "パスワード"}, true},
+		{"dbname=hello user=''", values{"dbname": "hello", "user": ""}, true},
+		{"user='' dbname=hello", values{"dbname": "hello", "user": ""}, true},
+		// The last option value is an empty string if there's no non-whitespace after its =
+		{"dbname=hello user=   ", values{"dbname": "hello", "user": ""}, true},
+
+		// The parser ignores spaces after = and interprets the next set of non-whitespace characters as the value.
+		{"user= password=foo", values{"user": "password=foo"}, true},
+
+		// Backslash escapes next char
+		{`user=a\ \'\\b`, values{"user": `a '\b`}, true},
+		{`user='a \'b'`, values{"user": `a 'b`}, true},
+
+		// Incomplete escape
+		{`user=x\`, values{}, false},
+
+		// No '=' after the key
+		{"postgre://marko@internet", values{}, false},
+		{"dbname user=goodbye", values{}, false},
+		{"user=foo blah", values{}, false},
+		{"user=foo blah   ", values{}, false},
+
+		// Unterminated quoted value
+		{"dbname=hello user='unterminated", values{}, false},
+	}
+
+	for _, test := range tests {
+		o := make(values)
+		err := parseOpts(test.in, o)
+
+		switch {
+		case err != nil && test.valid:
+			t.Errorf("%q got unexpected error: %s", test.in, err)
+		case err == nil && test.valid && !reflect.DeepEqual(test.expected, o):
+			t.Errorf("%q got: %#v want: %#v", test.in, o, test.expected)
+		case err == nil && !test.valid:
+			t.Errorf("%q expected an error", test.in)
+		}
+	}
+}
+
+func TestRuntimeParameters(t *testing.T) {
+	type RuntimeTestResult int
+	const (
+		ResultUnknown RuntimeTestResult = iota
+		ResultSuccess
+		ResultError // other error
+	)
+
+	tests := []struct {
+		conninfo        string
+		param           string
+		expected        string
+		expectedOutcome RuntimeTestResult
+	}{
+		// invalid parameter
+		{"DOESNOTEXIST=foo", "", "", ResultError},
+		// we can only work with a specific value for these two
+		{"client_encoding=SQL_ASCII", "", "", ResultError},
+		{"datestyle='ISO, YDM'", "", "", ResultError},
+		// "options" should work exactly as it does in libpq
+		{"options='-c search_path=pqgotest'", "search_path", "pqgotest", ResultSuccess},
+		// pq should override client_encoding in this case
+		{"options='-c client_encoding=SQL_ASCII'", "client_encoding", "UTF8", ResultSuccess},
+		// allow client_encoding to be set explicitly
+		{"client_encoding=UTF8", "client_encoding", "UTF8", ResultSuccess},
+		// test a runtime parameter not supported by libpq
+		{"work_mem='139kB'", "work_mem", "139kB", ResultSuccess},
+		// test fallback_application_name
+		{"application_name=foo fallback_application_name=bar", "application_name", "foo", ResultSuccess},
+		{"application_name='' fallback_application_name=bar", "application_name", "", ResultSuccess},
+		{"fallback_application_name=bar", "application_name", "bar", ResultSuccess},
+	}
+
+	for _, test := range tests {
+		db, err := openTestConnConninfo(test.conninfo)
+		if err != nil {
+			t.Fatal(err)
+		}
+
+		// application_name didn't exist before 9.0
+		if test.param == "application_name" && getServerVersion(t, db) < 90000 {
+			db.Close()
+			continue
+		}
+
+		tryGetParameterValue := func() (value string, outcome RuntimeTestResult) {
+			defer db.Close()
+			row := db.QueryRow("SELECT current_setting($1)", test.param)
+			err = row.Scan(&value)
+			if err != nil {
+				return "", ResultError
+			}
+			return value, ResultSuccess
+		}
+
+		value, outcome := tryGetParameterValue()
+		if outcome != test.expectedOutcome && outcome == ResultError {
+			t.Fatalf("%v: unexpected error: %v", test.conninfo, err)
+		}
+		if outcome != test.expectedOutcome {
+			t.Fatalf("unexpected outcome %v (was expecting %v) for conninfo \"%s\"",
+				outcome, test.expectedOutcome, test.conninfo)
+		}
+		if value != test.expected {
+			t.Fatalf("bad value for %s: got %s, want %s with conninfo \"%s\"",
+				test.param, value, test.expected, test.conninfo)
+		}
+	}
+}
+
+func TestIsUTF8(t *testing.T) {
+	var cases = []struct {
+		name string
+		want bool
+	}{
+		{"unicode", true},
+		{"utf-8", true},
+		{"utf_8", true},
+		{"UTF-8", true},
+		{"UTF8", true},
+		{"utf8", true},
+		{"u n ic_ode", true},
+		{"ut_f%8", true},
+		{"ubf8", false},
+		{"punycode", false},
+	}
+
+	for _, test := range cases {
+		if g := isUTF8(test.name); g != test.want {
+			t.Errorf("isUTF8(%q) = %v want %v", test.name, g, test.want)
+		}
+	}
+}
+
+func TestQuoteIdentifier(t *testing.T) {
+	var cases = []struct {
+		input string
+		want  string
+	}{
+		{`foo`, `"foo"`},
+		{`foo bar baz`, `"foo bar baz"`},
+		{`foo"bar`, `"foo""bar"`},
+		{"foo\x00bar", `"foo"`},
+		{"\x00foo", `""`},
+	}
+
+	for _, test := range cases {
+		got := QuoteIdentifier(test.input)
+		if got != test.want {
+			t.Errorf("QuoteIdentifier(%q) = %v want %v", test.input, got, test.want)
+		}
+	}
+}
+
+func TestRowsResultTag(t *testing.T) {
+	type ResultTag interface {
+		Result() driver.Result
+		Tag() string
+	}
+
+	tests := []struct {
+		query string
+		tag   string
+		ra    int64
+	}{
+		{
+			query: "CREATE TEMP TABLE temp (a int)",
+			tag:   "CREATE TABLE",
+		},
+		{
+			query: "INSERT INTO temp VALUES (1), (2)",
+			tag:   "INSERT",
+			ra:    2,
+		},
+		{
+			query: "SELECT 1",
+		},
+		// A SELECT anywhere should take precedent.
+		{
+			query: "SELECT 1; INSERT INTO temp VALUES (1), (2)",
+		},
+		{
+			query: "INSERT INTO temp VALUES (1), (2); SELECT 1",
+		},
+		// Multiple statements that don't return rows should return the last tag.
+		{
+			query: "CREATE TEMP TABLE t (a int); DROP TABLE t",
+			tag:   "DROP TABLE",
+		},
+		// Ensure a rows-returning query in any position among various tags-returing
+		// statements will prefer the rows.
+		{
+			query: "SELECT 1; CREATE TEMP TABLE t (a int); DROP TABLE t",
+		},
+		{
+			query: "CREATE TEMP TABLE t (a int); SELECT 1; DROP TABLE t",
+		},
+		{
+			query: "CREATE TEMP TABLE t (a int); DROP TABLE t; SELECT 1",
+		},
+		// Verify that an no-results query doesn't set the tag.
+		{
+			query: "CREATE TEMP TABLE t (a int); SELECT 1 WHERE FALSE; DROP TABLE t;",
+		},
+	}
+
+	// If this is the only test run, this will correct the connection string.
+	openTestConn(t).Close()
+
+	conn, err := Open("")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer conn.Close()
+	q := conn.(driver.Queryer)
+
+	for _, test := range tests {
+		if rows, err := q.Query(test.query, nil); err != nil {
+			t.Fatalf("%s: %s", test.query, err)
+		} else {
+			r := rows.(ResultTag)
+			if tag := r.Tag(); tag != test.tag {
+				t.Fatalf("%s: unexpected tag %q", test.query, tag)
+			}
+			res := r.Result()
+			if ra, _ := res.RowsAffected(); ra != test.ra {
+				t.Fatalf("%s: unexpected rows affected: %d", test.query, ra)
+			}
+			rows.Close()
+		}
+	}
+}
+
+// TestQuickClose tests that closing a query early allows a subsequent query to work.
+func TestQuickClose(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	tx, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	rows, err := tx.Query("SELECT 1; SELECT 2;")
+	if err != nil {
+		t.Fatal(err)
+	}
+	if err := rows.Close(); err != nil {
+		t.Fatal(err)
+	}
+
+	var id int
+	if err := tx.QueryRow("SELECT 3").Scan(&id); err != nil {
+		t.Fatal(err)
+	}
+	if id != 3 {
+		t.Fatalf("unexpected %d", id)
+	}
+	if err := tx.Commit(); err != nil {
+		t.Fatal(err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy.go
new file mode 100644
index 0000000..345c239
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy.go
@@ -0,0 +1,282 @@
+package pq
+
+import (
+	"database/sql/driver"
+	"encoding/binary"
+	"errors"
+	"fmt"
+	"sync"
+)
+
+var (
+	errCopyInClosed               = errors.New("pq: copyin statement has already been closed")
+	errBinaryCopyNotSupported     = errors.New("pq: only text format supported for COPY")
+	errCopyToNotSupported         = errors.New("pq: COPY TO is not supported")
+	errCopyNotSupportedOutsideTxn = errors.New("pq: COPY is only allowed inside a transaction")
+	errCopyInProgress             = errors.New("pq: COPY in progress")
+)
+
+// CopyIn creates a COPY FROM statement which can be prepared with
+// Tx.Prepare().  The target table should be visible in search_path.
+func CopyIn(table string, columns ...string) string {
+	stmt := "COPY " + QuoteIdentifier(table) + " ("
+	for i, col := range columns {
+		if i != 0 {
+			stmt += ", "
+		}
+		stmt += QuoteIdentifier(col)
+	}
+	stmt += ") FROM STDIN"
+	return stmt
+}
+
+// CopyInSchema creates a COPY FROM statement which can be prepared with
+// Tx.Prepare().
+func CopyInSchema(schema, table string, columns ...string) string {
+	stmt := "COPY " + QuoteIdentifier(schema) + "." + QuoteIdentifier(table) + " ("
+	for i, col := range columns {
+		if i != 0 {
+			stmt += ", "
+		}
+		stmt += QuoteIdentifier(col)
+	}
+	stmt += ") FROM STDIN"
+	return stmt
+}
+
+type copyin struct {
+	cn      *conn
+	buffer  []byte
+	rowData chan []byte
+	done    chan bool
+
+	closed bool
+
+	sync.Mutex // guards err
+	err        error
+}
+
+const ciBufferSize = 64 * 1024
+
+// flush buffer before the buffer is filled up and needs reallocation
+const ciBufferFlushSize = 63 * 1024
+
+func (cn *conn) prepareCopyIn(q string) (_ driver.Stmt, err error) {
+	if !cn.isInTransaction() {
+		return nil, errCopyNotSupportedOutsideTxn
+	}
+
+	ci := &copyin{
+		cn:      cn,
+		buffer:  make([]byte, 0, ciBufferSize),
+		rowData: make(chan []byte),
+		done:    make(chan bool, 1),
+	}
+	// add CopyData identifier + 4 bytes for message length
+	ci.buffer = append(ci.buffer, 'd', 0, 0, 0, 0)
+
+	b := cn.writeBuf('Q')
+	b.string(q)
+	cn.send(b)
+
+awaitCopyInResponse:
+	for {
+		t, r := cn.recv1()
+		switch t {
+		case 'G':
+			if r.byte() != 0 {
+				err = errBinaryCopyNotSupported
+				break awaitCopyInResponse
+			}
+			go ci.resploop()
+			return ci, nil
+		case 'H':
+			err = errCopyToNotSupported
+			break awaitCopyInResponse
+		case 'E':
+			err = parseError(r)
+		case 'Z':
+			if err == nil {
+				ci.setBad()
+				errorf("unexpected ReadyForQuery in response to COPY")
+			}
+			cn.processReadyForQuery(r)
+			return nil, err
+		default:
+			ci.setBad()
+			errorf("unknown response for copy query: %q", t)
+		}
+	}
+
+	// something went wrong, abort COPY before we return
+	b = cn.writeBuf('f')
+	b.string(err.Error())
+	cn.send(b)
+
+	for {
+		t, r := cn.recv1()
+		switch t {
+		case 'c', 'C', 'E':
+		case 'Z':
+			// correctly aborted, we're done
+			cn.processReadyForQuery(r)
+			return nil, err
+		default:
+			ci.setBad()
+			errorf("unknown response for CopyFail: %q", t)
+		}
+	}
+}
+
+func (ci *copyin) flush(buf []byte) {
+	// set message length (without message identifier)
+	binary.BigEndian.PutUint32(buf[1:], uint32(len(buf)-1))
+
+	_, err := ci.cn.c.Write(buf)
+	if err != nil {
+		panic(err)
+	}
+}
+
+func (ci *copyin) resploop() {
+	for {
+		var r readBuf
+		t, err := ci.cn.recvMessage(&r)
+		if err != nil {
+			ci.setBad()
+			ci.setError(err)
+			ci.done <- true
+			return
+		}
+		switch t {
+		case 'C':
+			// complete
+		case 'N':
+			// NoticeResponse
+		case 'Z':
+			ci.cn.processReadyForQuery(&r)
+			ci.done <- true
+			return
+		case 'E':
+			err := parseError(&r)
+			ci.setError(err)
+		default:
+			ci.setBad()
+			ci.setError(fmt.Errorf("unknown response during CopyIn: %q", t))
+			ci.done <- true
+			return
+		}
+	}
+}
+
+func (ci *copyin) setBad() {
+	ci.Lock()
+	ci.cn.bad = true
+	ci.Unlock()
+}
+
+func (ci *copyin) isBad() bool {
+	ci.Lock()
+	b := ci.cn.bad
+	ci.Unlock()
+	return b
+}
+
+func (ci *copyin) isErrorSet() bool {
+	ci.Lock()
+	isSet := (ci.err != nil)
+	ci.Unlock()
+	return isSet
+}
+
+// setError() sets ci.err if one has not been set already.  Caller must not be
+// holding ci.Mutex.
+func (ci *copyin) setError(err error) {
+	ci.Lock()
+	if ci.err == nil {
+		ci.err = err
+	}
+	ci.Unlock()
+}
+
+func (ci *copyin) NumInput() int {
+	return -1
+}
+
+func (ci *copyin) Query(v []driver.Value) (r driver.Rows, err error) {
+	return nil, ErrNotSupported
+}
+
+// Exec inserts values into the COPY stream. The insert is asynchronous
+// and Exec can return errors from previous Exec calls to the same
+// COPY stmt.
+//
+// You need to call Exec(nil) to sync the COPY stream and to get any
+// errors from pending data, since Stmt.Close() doesn't return errors
+// to the user.
+func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) {
+	if ci.closed {
+		return nil, errCopyInClosed
+	}
+
+	if ci.isBad() {
+		return nil, driver.ErrBadConn
+	}
+	defer ci.cn.errRecover(&err)
+
+	if ci.isErrorSet() {
+		return nil, ci.err
+	}
+
+	if len(v) == 0 {
+		return nil, ci.Close()
+	}
+
+	numValues := len(v)
+	for i, value := range v {
+		ci.buffer = appendEncodedText(&ci.cn.parameterStatus, ci.buffer, value)
+		if i < numValues-1 {
+			ci.buffer = append(ci.buffer, '\t')
+		}
+	}
+
+	ci.buffer = append(ci.buffer, '\n')
+
+	if len(ci.buffer) > ciBufferFlushSize {
+		ci.flush(ci.buffer)
+		// reset buffer, keep bytes for message identifier and length
+		ci.buffer = ci.buffer[:5]
+	}
+
+	return driver.RowsAffected(0), nil
+}
+
+func (ci *copyin) Close() (err error) {
+	if ci.closed { // Don't do anything, we're already closed
+		return nil
+	}
+	ci.closed = true
+
+	if ci.isBad() {
+		return driver.ErrBadConn
+	}
+	defer ci.cn.errRecover(&err)
+
+	if len(ci.buffer) > 0 {
+		ci.flush(ci.buffer)
+	}
+	// Avoid touching the scratch buffer as resploop could be using it.
+	err = ci.cn.sendSimpleMessage('c')
+	if err != nil {
+		return err
+	}
+
+	<-ci.done
+	ci.cn.inCopy = false
+
+	if ci.isErrorSet() {
+		err = ci.err
+		return err
+	}
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy_test.go
new file mode 100644
index 0000000..86745b3
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/copy_test.go
@@ -0,0 +1,465 @@
+package pq
+
+import (
+	"bytes"
+	"database/sql"
+	"database/sql/driver"
+	"strings"
+	"testing"
+)
+
+func TestCopyInStmt(t *testing.T) {
+	var stmt string
+	stmt = CopyIn("table name")
+	if stmt != `COPY "table name" () FROM STDIN` {
+		t.Fatal(stmt)
+	}
+
+	stmt = CopyIn("table name", "column 1", "column 2")
+	if stmt != `COPY "table name" ("column 1", "column 2") FROM STDIN` {
+		t.Fatal(stmt)
+	}
+
+	stmt = CopyIn(`table " name """`, `co"lumn""`)
+	if stmt != `COPY "table "" name """"""" ("co""lumn""""") FROM STDIN` {
+		t.Fatal(stmt)
+	}
+}
+
+func TestCopyInSchemaStmt(t *testing.T) {
+	var stmt string
+	stmt = CopyInSchema("schema name", "table name")
+	if stmt != `COPY "schema name"."table name" () FROM STDIN` {
+		t.Fatal(stmt)
+	}
+
+	stmt = CopyInSchema("schema name", "table name", "column 1", "column 2")
+	if stmt != `COPY "schema name"."table name" ("column 1", "column 2") FROM STDIN` {
+		t.Fatal(stmt)
+	}
+
+	stmt = CopyInSchema(`schema " name """`, `table " name """`, `co"lumn""`)
+	if stmt != `COPY "schema "" name """"""".`+
+		`"table "" name """"""" ("co""lumn""""") FROM STDIN` {
+		t.Fatal(stmt)
+	}
+}
+
+func TestCopyInMultipleValues(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (a int, b varchar)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	stmt, err := txn.Prepare(CopyIn("temp", "a", "b"))
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	longString := strings.Repeat("#", 500)
+
+	for i := 0; i < 500; i++ {
+		_, err = stmt.Exec(int64(i), longString)
+		if err != nil {
+			t.Fatal(err)
+		}
+	}
+
+	_, err = stmt.Exec()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = stmt.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var num int
+	err = txn.QueryRow("SELECT COUNT(*) FROM temp").Scan(&num)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if num != 500 {
+		t.Fatalf("expected 500 items, not %d", num)
+	}
+}
+
+func TestCopyInRaiseStmtTrigger(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	if getServerVersion(t, db) < 90000 {
+		var exists int
+		err := db.QueryRow("SELECT 1 FROM pg_language WHERE lanname = 'plpgsql'").Scan(&exists)
+		if err == sql.ErrNoRows {
+			t.Skip("language PL/PgSQL does not exist; skipping TestCopyInRaiseStmtTrigger")
+		} else if err != nil {
+			t.Fatal(err)
+		}
+	}
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (a int, b varchar)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = txn.Exec(`
+			CREATE OR REPLACE FUNCTION pg_temp.temptest()
+			RETURNS trigger AS 
+			$BODY$ begin
+				raise notice 'Hello world';
+				return new;
+			end $BODY$
+			LANGUAGE plpgsql`)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = txn.Exec(`
+			CREATE TRIGGER temptest_trigger
+			BEFORE INSERT
+			ON temp 
+			FOR EACH ROW
+			EXECUTE PROCEDURE pg_temp.temptest()`)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	stmt, err := txn.Prepare(CopyIn("temp", "a", "b"))
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	longString := strings.Repeat("#", 500)
+
+	_, err = stmt.Exec(int64(1), longString)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = stmt.Exec()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = stmt.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var num int
+	err = txn.QueryRow("SELECT COUNT(*) FROM temp").Scan(&num)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if num != 1 {
+		t.Fatalf("expected 1 items, not %d", num)
+	}
+}
+
+func TestCopyInTypes(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (num INTEGER, text VARCHAR, blob BYTEA, nothing VARCHAR)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	stmt, err := txn.Prepare(CopyIn("temp", "num", "text", "blob", "nothing"))
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = stmt.Exec(int64(1234567890), "Héllö\n ☃!\r\t\\", []byte{0, 255, 9, 10, 13}, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = stmt.Exec()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = stmt.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var num int
+	var text string
+	var blob []byte
+	var nothing sql.NullString
+
+	err = txn.QueryRow("SELECT * FROM temp").Scan(&num, &text, &blob, &nothing)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if num != 1234567890 {
+		t.Fatal("unexpected result", num)
+	}
+	if text != "Héllö\n ☃!\r\t\\" {
+		t.Fatal("unexpected result", text)
+	}
+	if bytes.Compare(blob, []byte{0, 255, 9, 10, 13}) != 0 {
+		t.Fatal("unexpected result", blob)
+	}
+	if nothing.Valid {
+		t.Fatal("unexpected result", nothing.String)
+	}
+}
+
+func TestCopyInWrongType(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (num INTEGER)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	stmt, err := txn.Prepare(CopyIn("temp", "num"))
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer stmt.Close()
+
+	_, err = stmt.Exec("Héllö\n ☃!\r\t\\")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = stmt.Exec()
+	if err == nil {
+		t.Fatal("expected error")
+	}
+	if pge := err.(*Error); pge.Code.Name() != "invalid_text_representation" {
+		t.Fatalf("expected 'invalid input syntax for integer' error, got %s (%+v)", pge.Code.Name(), pge)
+	}
+}
+
+func TestCopyOutsideOfTxnError(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	_, err := db.Prepare(CopyIn("temp", "num"))
+	if err == nil {
+		t.Fatal("COPY outside of transaction did not return an error")
+	}
+	if err != errCopyNotSupportedOutsideTxn {
+		t.Fatalf("expected %s, got %s", err, err.Error())
+	}
+}
+
+func TestCopyInBinaryError(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (num INTEGER)")
+	if err != nil {
+		t.Fatal(err)
+	}
+	_, err = txn.Prepare("COPY temp (num) FROM STDIN WITH binary")
+	if err != errBinaryCopyNotSupported {
+		t.Fatalf("expected %s, got %+v", errBinaryCopyNotSupported, err)
+	}
+	// check that the protocol is in a valid state
+	err = txn.Rollback()
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestCopyFromError(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (num INTEGER)")
+	if err != nil {
+		t.Fatal(err)
+	}
+	_, err = txn.Prepare("COPY temp (num) TO STDOUT")
+	if err != errCopyToNotSupported {
+		t.Fatalf("expected %s, got %+v", errCopyToNotSupported, err)
+	}
+	// check that the protocol is in a valid state
+	err = txn.Rollback()
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestCopySyntaxError(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Prepare("COPY ")
+	if err == nil {
+		t.Fatal("expected error")
+	}
+	if pge := err.(*Error); pge.Code.Name() != "syntax_error" {
+		t.Fatalf("expected syntax error, got %s (%+v)", pge.Code.Name(), pge)
+	}
+	// check that the protocol is in a valid state
+	err = txn.Rollback()
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+// Tests for connection errors in copyin.resploop()
+func TestCopyRespLoopConnectionError(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	var pid int
+	err = txn.QueryRow("SELECT pg_backend_pid()").Scan(&pid)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (a int)")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	stmt, err := txn.Prepare(CopyIn("temp", "a"))
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer stmt.Close()
+
+	_, err = db.Exec("SELECT pg_terminate_backend($1)", pid)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if getServerVersion(t, db) < 90500 {
+		// We have to try and send something over, since postgres before
+		// version 9.5 won't process SIGTERMs while it's waiting for
+		// CopyData/CopyEnd messages; see tcop/postgres.c.
+		_, err = stmt.Exec(1)
+		if err != nil {
+			t.Fatal(err)
+		}
+	}
+	_, err = stmt.Exec()
+	if err == nil {
+		t.Fatalf("expected error")
+	}
+	pge, ok := err.(*Error)
+	if !ok {
+		if err == driver.ErrBadConn {
+			// likely an EPIPE
+		} else {
+			t.Fatalf("expected *pq.Error or driver.ErrBadConn, got %+#v", err)
+		}
+	} else if pge.Code.Name() != "admin_shutdown" {
+		t.Fatalf("expected admin_shutdown, got %s", pge.Code.Name())
+	}
+
+	_ = stmt.Close()
+}
+
+func BenchmarkCopyIn(b *testing.B) {
+	db := openTestConn(b)
+	defer db.Close()
+
+	txn, err := db.Begin()
+	if err != nil {
+		b.Fatal(err)
+	}
+	defer txn.Rollback()
+
+	_, err = txn.Exec("CREATE TEMP TABLE temp (a int, b varchar)")
+	if err != nil {
+		b.Fatal(err)
+	}
+
+	stmt, err := txn.Prepare(CopyIn("temp", "a", "b"))
+	if err != nil {
+		b.Fatal(err)
+	}
+
+	for i := 0; i < b.N; i++ {
+		_, err = stmt.Exec(int64(i), "hello world!")
+		if err != nil {
+			b.Fatal(err)
+		}
+	}
+
+	_, err = stmt.Exec()
+	if err != nil {
+		b.Fatal(err)
+	}
+
+	err = stmt.Close()
+	if err != nil {
+		b.Fatal(err)
+	}
+
+	var num int
+	err = txn.QueryRow("SELECT COUNT(*) FROM temp").Scan(&num)
+	if err != nil {
+		b.Fatal(err)
+	}
+
+	if num != b.N {
+		b.Fatalf("expected %d items, not %d", b.N, num)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/doc.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/doc.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/doc.go
new file mode 100644
index 0000000..6d252ec
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/doc.go
@@ -0,0 +1,235 @@
+/*
+Package pq is a pure Go Postgres driver for the database/sql package.
+
+In most cases clients will use the database/sql package instead of
+using this package directly. For example:
+
+	import (
+		"database/sql"
+
+		_ "github.com/lib/pq"
+	)
+
+	func main() {
+		db, err := sql.Open("postgres", "user=pqgotest dbname=pqgotest sslmode=verify-full")
+		if err != nil {
+			log.Fatal(err)
+		}
+
+		age := 21
+		rows, err := db.Query("SELECT name FROM users WHERE age = $1", age)
+		…
+	}
+
+You can also connect to a database using a URL. For example:
+
+	db, err := sql.Open("postgres", "postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full")
+
+
+Connection String Parameters
+
+
+Similarly to libpq, when establishing a connection using pq you are expected to
+supply a connection string containing zero or more parameters.
+A subset of the connection parameters supported by libpq are also supported by pq.
+Additionally, pq also lets you specify run-time parameters (such as search_path or work_mem)
+directly in the connection string.  This is different from libpq, which does not allow
+run-time parameters in the connection string, instead requiring you to supply
+them in the options parameter.
+
+For compatibility with libpq, the following special connection parameters are
+supported:
+
+	* dbname - The name of the database to connect to
+	* user - The user to sign in as
+	* password - The user's password
+	* host - The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
+	* port - The port to bind to. (default is 5432)
+	* sslmode - Whether or not to use SSL (default is require, this is not the default for libpq)
+	* fallback_application_name - An application_name to fall back to if one isn't provided.
+	* connect_timeout - Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
+	* sslcert - Cert file location. The file must contain PEM encoded data.
+	* sslkey - Key file location. The file must contain PEM encoded data.
+	* sslrootcert - The location of the root certificate file. The file must contain PEM encoded data.
+
+Valid values for sslmode are:
+
+	* disable - No SSL
+	* require - Always SSL (skip verification)
+	* verify-ca - Always SSL (verify that the certificate presented by the server was signed by a trusted CA)
+	* verify-full - Always SSL (verify that the certification presented by the server was signed by a trusted CA and the server host name matches the one in the certificate)
+
+See http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
+for more information about connection string parameters.
+
+Use single quotes for values that contain whitespace:
+
+    "user=pqgotest password='with spaces'"
+
+A backslash will escape the next character in values:
+
+    "user=space\ man password='it\'s valid'
+
+Note that the connection parameter client_encoding (which sets the
+text encoding for the connection) may be set but must be "UTF8",
+matching with the same rules as Postgres. It is an error to provide
+any other value.
+
+In addition to the parameters listed above, any run-time parameter that can be
+set at backend start time can be set in the connection string.  For more
+information, see
+http://www.postgresql.org/docs/current/static/runtime-config.html.
+
+Most environment variables as specified at http://www.postgresql.org/docs/current/static/libpq-envars.html
+supported by libpq are also supported by pq.  If any of the environment
+variables not supported by pq are set, pq will panic during connection
+establishment.  Environment variables have a lower precedence than explicitly
+provided connection parameters.
+
+The pgpass mechanism as described in http://www.postgresql.org/docs/current/static/libpq-pgpass.html
+is supported, but on Windows PGPASSFILE must be specified explicitly.
+
+
+Queries
+
+
+database/sql does not dictate any specific format for parameter
+markers in query strings, and pq uses the Postgres-native ordinal markers,
+as shown above. The same marker can be reused for the same parameter:
+
+	rows, err := db.Query(`SELECT name FROM users WHERE favorite_fruit = $1
+		OR age BETWEEN $2 AND $2 + 3`, "orange", 64)
+
+pq does not support the LastInsertId() method of the Result type in database/sql.
+To return the identifier of an INSERT (or UPDATE or DELETE), use the Postgres
+RETURNING clause with a standard Query or QueryRow call:
+
+	var userid int
+	err := db.QueryRow(`INSERT INTO users(name, favorite_fruit, age)
+		VALUES('beatrice', 'starfruit', 93) RETURNING id`).Scan(&userid)
+
+For more details on RETURNING, see the Postgres documentation:
+
+	http://www.postgresql.org/docs/current/static/sql-insert.html
+	http://www.postgresql.org/docs/current/static/sql-update.html
+	http://www.postgresql.org/docs/current/static/sql-delete.html
+
+For additional instructions on querying see the documentation for the database/sql package.
+
+
+Data Types
+
+
+Parameters pass through driver.DefaultParameterConverter before they are handled
+by this package. When the binary_parameters connection option is enabled,
+[]byte values are sent directly to the backend as data in binary format.
+
+This package returns the following types for values from the PostgreSQL backend:
+
+	- integer types smallint, integer, and bigint are returned as int64
+	- floating-point types real and double precision are returned as float64
+	- character types char, varchar, and text are returned as string
+	- temporal types date, time, timetz, timestamp, and timestamptz are returned as time.Time
+	- the boolean type is returned as bool
+	- the bytea type is returned as []byte
+
+All other types are returned directly from the backend as []byte values in text format.
+
+
+Errors
+
+
+pq may return errors of type *pq.Error which can be interrogated for error details:
+
+        if err, ok := err.(*pq.Error); ok {
+            fmt.Println("pq error:", err.Code.Name())
+        }
+
+See the pq.Error type for details.
+
+
+Bulk imports
+
+You can perform bulk imports by preparing a statement returned by pq.CopyIn (or
+pq.CopyInSchema) in an explicit transaction (sql.Tx). The returned statement
+handle can then be repeatedly "executed" to copy data into the target table.
+After all data has been processed you should call Exec() once with no arguments
+to flush all buffered data. Any call to Exec() might return an error which
+should be handled appropriately, but because of the internal buffering an error
+returned by Exec() might not be related to the data passed in the call that
+failed.
+
+CopyIn uses COPY FROM internally. It is not possible to COPY outside of an
+explicit transaction in pq.
+
+Usage example:
+
+	txn, err := db.Begin()
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	stmt, err := txn.Prepare(pq.CopyIn("users", "name", "age"))
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	for _, user := range users {
+		_, err = stmt.Exec(user.Name, int64(user.Age))
+		if err != nil {
+			log.Fatal(err)
+		}
+	}
+
+	_, err = stmt.Exec()
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	err = stmt.Close()
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	err = txn.Commit()
+	if err != nil {
+		log.Fatal(err)
+	}
+
+
+Notifications
+
+
+PostgreSQL supports a simple publish/subscribe model over database
+connections.  See http://www.postgresql.org/docs/current/static/sql-notify.html
+for more information about the general mechanism.
+
+To start listening for notifications, you first have to open a new connection
+to the database by calling NewListener.  This connection can not be used for
+anything other than LISTEN / NOTIFY.  Calling Listen will open a "notification
+channel"; once a notification channel is open, a notification generated on that
+channel will effect a send on the Listener.Notify channel.  A notification
+channel will remain open until Unlisten is called, though connection loss might
+result in some notifications being lost.  To solve this problem, Listener sends
+a nil pointer over the Notify channel any time the connection is re-established
+following a connection loss.  The application can get information about the
+state of the underlying connection by setting an event callback in the call to
+NewListener.
+
+A single Listener can safely be used from concurrent goroutines, which means
+that there is often no need to create more than one Listener in your
+application.  However, a Listener is always connected to a single database, so
+you will need to create a new Listener instance for every database you want to
+receive notifications in.
+
+The channel name in both Listen and Unlisten is case sensitive, and can contain
+any characters legal in an identifier (see
+http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
+for more information).  Note that the channel name will be truncated to 63
+bytes by the PostgreSQL server.
+
+You can find a complete, working example of Listener usage at
+http://godoc.org/github.com/lib/pq/listen_example.
+
+*/
+package pq

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode.go
new file mode 100644
index 0000000..88a322c
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode.go
@@ -0,0 +1,595 @@
+package pq
+
+import (
+	"bytes"
+	"database/sql/driver"
+	"encoding/binary"
+	"encoding/hex"
+	"errors"
+	"fmt"
+	"math"
+	"strconv"
+	"strings"
+	"sync"
+	"time"
+
+	"github.com/lib/pq/oid"
+)
+
+func binaryEncode(parameterStatus *parameterStatus, x interface{}) []byte {
+	switch v := x.(type) {
+	case []byte:
+		return v
+	default:
+		return encode(parameterStatus, x, oid.T_unknown)
+	}
+}
+
+func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) []byte {
+	switch v := x.(type) {
+	case int64:
+		return strconv.AppendInt(nil, v, 10)
+	case float64:
+		return strconv.AppendFloat(nil, v, 'f', -1, 64)
+	case []byte:
+		if pgtypOid == oid.T_bytea {
+			return encodeBytea(parameterStatus.serverVersion, v)
+		}
+
+		return v
+	case string:
+		if pgtypOid == oid.T_bytea {
+			return encodeBytea(parameterStatus.serverVersion, []byte(v))
+		}
+
+		return []byte(v)
+	case bool:
+		return strconv.AppendBool(nil, v)
+	case time.Time:
+		return formatTs(v)
+
+	default:
+		errorf("encode: unknown type for %T", v)
+	}
+
+	panic("not reached")
+}
+
+func decode(parameterStatus *parameterStatus, s []byte, typ oid.Oid, f format) interface{} {
+	switch f {
+	case formatBinary:
+		return binaryDecode(parameterStatus, s, typ)
+	case formatText:
+		return textDecode(parameterStatus, s, typ)
+	default:
+		panic("not reached")
+	}
+}
+
+func binaryDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) interface{} {
+	switch typ {
+	case oid.T_bytea:
+		return s
+	case oid.T_int8:
+		return int64(binary.BigEndian.Uint64(s))
+	case oid.T_int4:
+		return int64(int32(binary.BigEndian.Uint32(s)))
+	case oid.T_int2:
+		return int64(int16(binary.BigEndian.Uint16(s)))
+	case oid.T_uuid:
+		b, err := decodeUUIDBinary(s)
+		if err != nil {
+			panic(err)
+		}
+		return b
+
+	default:
+		errorf("don't know how to decode binary parameter of type %d", uint32(typ))
+	}
+
+	panic("not reached")
+}
+
+func textDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) interface{} {
+	switch typ {
+	case oid.T_char, oid.T_varchar, oid.T_text:
+		return string(s)
+	case oid.T_bytea:
+		b, err := parseBytea(s)
+		if err != nil {
+			errorf("%s", err)
+		}
+		return b
+	case oid.T_timestamptz:
+		return parseTs(parameterStatus.currentLocation, string(s))
+	case oid.T_timestamp, oid.T_date:
+		return parseTs(nil, string(s))
+	case oid.T_time:
+		return mustParse("15:04:05", typ, s)
+	case oid.T_timetz:
+		return mustParse("15:04:05-07", typ, s)
+	case oid.T_bool:
+		return s[0] == 't'
+	case oid.T_int8, oid.T_int4, oid.T_int2:
+		i, err := strconv.ParseInt(string(s), 10, 64)
+		if err != nil {
+			errorf("%s", err)
+		}
+		return i
+	case oid.T_float4, oid.T_float8:
+		bits := 64
+		if typ == oid.T_float4 {
+			bits = 32
+		}
+		f, err := strconv.ParseFloat(string(s), bits)
+		if err != nil {
+			errorf("%s", err)
+		}
+		return f
+	}
+
+	return s
+}
+
+// appendEncodedText encodes item in text format as required by COPY
+// and appends to buf
+func appendEncodedText(parameterStatus *parameterStatus, buf []byte, x interface{}) []byte {
+	switch v := x.(type) {
+	case int64:
+		return strconv.AppendInt(buf, v, 10)
+	case float64:
+		return strconv.AppendFloat(buf, v, 'f', -1, 64)
+	case []byte:
+		encodedBytea := encodeBytea(parameterStatus.serverVersion, v)
+		return appendEscapedText(buf, string(encodedBytea))
+	case string:
+		return appendEscapedText(buf, v)
+	case bool:
+		return strconv.AppendBool(buf, v)
+	case time.Time:
+		return append(buf, formatTs(v)...)
+	case nil:
+		return append(buf, "\\N"...)
+	default:
+		errorf("encode: unknown type for %T", v)
+	}
+
+	panic("not reached")
+}
+
+func appendEscapedText(buf []byte, text string) []byte {
+	escapeNeeded := false
+	startPos := 0
+	var c byte
+
+	// check if we need to escape
+	for i := 0; i < len(text); i++ {
+		c = text[i]
+		if c == '\\' || c == '\n' || c == '\r' || c == '\t' {
+			escapeNeeded = true
+			startPos = i
+			break
+		}
+	}
+	if !escapeNeeded {
+		return append(buf, text...)
+	}
+
+	// copy till first char to escape, iterate the rest
+	result := append(buf, text[:startPos]...)
+	for i := startPos; i < len(text); i++ {
+		c = text[i]
+		switch c {
+		case '\\':
+			result = append(result, '\\', '\\')
+		case '\n':
+			result = append(result, '\\', 'n')
+		case '\r':
+			result = append(result, '\\', 'r')
+		case '\t':
+			result = append(result, '\\', 't')
+		default:
+			result = append(result, c)
+		}
+	}
+	return result
+}
+
+func mustParse(f string, typ oid.Oid, s []byte) time.Time {
+	str := string(s)
+
+	// check for a 30-minute-offset timezone
+	if (typ == oid.T_timestamptz || typ == oid.T_timetz) &&
+		str[len(str)-3] == ':' {
+		f += ":00"
+	}
+	t, err := time.Parse(f, str)
+	if err != nil {
+		errorf("decode: %s", err)
+	}
+	return t
+}
+
+var errInvalidTimestamp = errors.New("invalid timestamp")
+
+type timestampParser struct {
+	err error
+}
+
+func (p *timestampParser) expect(str string, char byte, pos int) {
+	if p.err != nil {
+		return
+	}
+	if pos+1 > len(str) {
+		p.err = errInvalidTimestamp
+		return
+	}
+	if c := str[pos]; c != char && p.err == nil {
+		p.err = fmt.Errorf("expected '%v' at position %v; got '%v'", char, pos, c)
+	}
+}
+
+func (p *timestampParser) mustAtoi(str string, begin int, end int) int {
+	if p.err != nil {
+		return 0
+	}
+	if begin < 0 || end < 0 || begin > end || end > len(str) {
+		p.err = errInvalidTimestamp
+		return 0
+	}
+	result, err := strconv.Atoi(str[begin:end])
+	if err != nil {
+		if p.err == nil {
+			p.err = fmt.Errorf("expected number; got '%v'", str)
+		}
+		return 0
+	}
+	return result
+}
+
+// The location cache caches the time zones typically used by the client.
+type locationCache struct {
+	cache map[int]*time.Location
+	lock  sync.Mutex
+}
+
+// All connections share the same list of timezones. Benchmarking shows that
+// about 5% speed could be gained by putting the cache in the connection and
+// losing the mutex, at the cost of a small amount of memory and a somewhat
+// significant increase in code complexity.
+var globalLocationCache = newLocationCache()
+
+func newLocationCache() *locationCache {
+	return &locationCache{cache: make(map[int]*time.Location)}
+}
+
+// Returns the cached timezone for the specified offset, creating and caching
+// it if necessary.
+func (c *locationCache) getLocation(offset int) *time.Location {
+	c.lock.Lock()
+	defer c.lock.Unlock()
+
+	location, ok := c.cache[offset]
+	if !ok {
+		location = time.FixedZone("", offset)
+		c.cache[offset] = location
+	}
+
+	return location
+}
+
+var infinityTsEnabled = false
+var infinityTsNegative time.Time
+var infinityTsPositive time.Time
+
+const (
+	infinityTsEnabledAlready        = "pq: infinity timestamp enabled already"
+	infinityTsNegativeMustBeSmaller = "pq: infinity timestamp: negative value must be smaller (before) than positive"
+)
+
+// EnableInfinityTs controls the handling of Postgres' "-infinity" and
+// "infinity" "timestamp"s.
+//
+// If EnableInfinityTs is not called, "-infinity" and "infinity" will return
+// []byte("-infinity") and []byte("infinity") respectively, and potentially
+// cause error "sql: Scan error on column index 0: unsupported driver -> Scan
+// pair: []uint8 -> *time.Time", when scanning into a time.Time value.
+//
+// Once EnableInfinityTs has been called, all connections created using this
+// driver will decode Postgres' "-infinity" and "infinity" for "timestamp",
+// "timestamp with time zone" and "date" types to the predefined minimum and
+// maximum times, respectively.  When encoding time.Time values, any time which
+// equals or precedes the predefined minimum time will be encoded to
+// "-infinity".  Any values at or past the maximum time will similarly be
+// encoded to "infinity".
+//
+// If EnableInfinityTs is called with negative >= positive, it will panic.
+// Calling EnableInfinityTs after a connection has been established results in
+// undefined behavior.  If EnableInfinityTs is called more than once, it will
+// panic.
+func EnableInfinityTs(negative time.Time, positive time.Time) {
+	if infinityTsEnabled {
+		panic(infinityTsEnabledAlready)
+	}
+	if !negative.Before(positive) {
+		panic(infinityTsNegativeMustBeSmaller)
+	}
+	infinityTsEnabled = true
+	infinityTsNegative = negative
+	infinityTsPositive = positive
+}
+
+/*
+ * Testing might want to toggle infinityTsEnabled
+ */
+func disableInfinityTs() {
+	infinityTsEnabled = false
+}
+
+// This is a time function specific to the Postgres default DateStyle
+// setting ("ISO, MDY"), the only one we currently support. This
+// accounts for the discrepancies between the parsing available with
+// time.Parse and the Postgres date formatting quirks.
+func parseTs(currentLocation *time.Location, str string) interface{} {
+	switch str {
+	case "-infinity":
+		if infinityTsEnabled {
+			return infinityTsNegative
+		}
+		return []byte(str)
+	case "infinity":
+		if infinityTsEnabled {
+			return infinityTsPositive
+		}
+		return []byte(str)
+	}
+	t, err := ParseTimestamp(currentLocation, str)
+	if err != nil {
+		panic(err)
+	}
+	return t
+}
+
+// ParseTimestamp parses Postgres' text format. It returns a time.Time in
+// currentLocation iff that time's offset agrees with the offset sent from the
+// Postgres server. Otherwise, ParseTimestamp returns a time.Time with the
+// fixed offset offset provided by the Postgres server.
+func ParseTimestamp(currentLocation *time.Location, str string) (time.Time, error) {
+	p := timestampParser{}
+
+	monSep := strings.IndexRune(str, '-')
+	// this is Gregorian year, not ISO Year
+	// In Gregorian system, the year 1 BC is followed by AD 1
+	year := p.mustAtoi(str, 0, monSep)
+	daySep := monSep + 3
+	month := p.mustAtoi(str, monSep+1, daySep)
+	p.expect(str, '-', daySep)
+	timeSep := daySep + 3
+	day := p.mustAtoi(str, daySep+1, timeSep)
+
+	var hour, minute, second int
+	if len(str) > monSep+len("01-01")+1 {
+		p.expect(str, ' ', timeSep)
+		minSep := timeSep + 3
+		p.expect(str, ':', minSep)
+		hour = p.mustAtoi(str, timeSep+1, minSep)
+		secSep := minSep + 3
+		p.expect(str, ':', secSep)
+		minute = p.mustAtoi(str, minSep+1, secSep)
+		secEnd := secSep + 3
+		second = p.mustAtoi(str, secSep+1, secEnd)
+	}
+	remainderIdx := monSep + len("01-01 00:00:00") + 1
+	// Three optional (but ordered) sections follow: the
+	// fractional seconds, the time zone offset, and the BC
+	// designation. We set them up here and adjust the other
+	// offsets if the preceding sections exist.
+
+	nanoSec := 0
+	tzOff := 0
+
+	if remainderIdx < len(str) && str[remainderIdx] == '.' {
+		fracStart := remainderIdx + 1
+		fracOff := strings.IndexAny(str[fracStart:], "-+ ")
+		if fracOff < 0 {
+			fracOff = len(str) - fracStart
+		}
+		fracSec := p.mustAtoi(str, fracStart, fracStart+fracOff)
+		nanoSec = fracSec * (1000000000 / int(math.Pow(10, float64(fracOff))))
+
+		remainderIdx += fracOff + 1
+	}
+	if tzStart := remainderIdx; tzStart < len(str) && (str[tzStart] == '-' || str[tzStart] == '+') {
+		// time zone separator is always '-' or '+' (UTC is +00)
+		var tzSign int
+		switch c := str[tzStart]; c {
+		case '-':
+			tzSign = -1
+		case '+':
+			tzSign = +1
+		default:
+			return time.Time{}, fmt.Errorf("expected '-' or '+' at position %v; got %v", tzStart, c)
+		}
+		tzHours := p.mustAtoi(str, tzStart+1, tzStart+3)
+		remainderIdx += 3
+		var tzMin, tzSec int
+		if remainderIdx < len(str) && str[remainderIdx] == ':' {
+			tzMin = p.mustAtoi(str, remainderIdx+1, remainderIdx+3)
+			remainderIdx += 3
+		}
+		if remainderIdx < len(str) && str[remainderIdx] == ':' {
+			tzSec = p.mustAtoi(str, remainderIdx+1, remainderIdx+3)
+			remainderIdx += 3
+		}
+		tzOff = tzSign * ((tzHours * 60 * 60) + (tzMin * 60) + tzSec)
+	}
+	var isoYear int
+	if remainderIdx+3 <= len(str) && str[remainderIdx:remainderIdx+3] == " BC" {
+		isoYear = 1 - year
+		remainderIdx += 3
+	} else {
+		isoYear = year
+	}
+	if remainderIdx < len(str) {
+		return time.Time{}, fmt.Errorf("expected end of input, got %v", str[remainderIdx:])
+	}
+	t := time.Date(isoYear, time.Month(month), day,
+		hour, minute, second, nanoSec,
+		globalLocationCache.getLocation(tzOff))
+
+	if currentLocation != nil {
+		// Set the location of the returned Time based on the session's
+		// TimeZone value, but only if the local time zone database agrees with
+		// the remote database on the offset.
+		lt := t.In(currentLocation)
+		_, newOff := lt.Zone()
+		if newOff == tzOff {
+			t = lt
+		}
+	}
+
+	return t, p.err
+}
+
+// formatTs formats t into a format postgres understands.
+func formatTs(t time.Time) []byte {
+	if infinityTsEnabled {
+		// t <= -infinity : ! (t > -infinity)
+		if !t.After(infinityTsNegative) {
+			return []byte("-infinity")
+		}
+		// t >= infinity : ! (!t < infinity)
+		if !t.Before(infinityTsPositive) {
+			return []byte("infinity")
+		}
+	}
+	return FormatTimestamp(t)
+}
+
+// FormatTimestamp formats t into Postgres' text format for timestamps.
+func FormatTimestamp(t time.Time) []byte {
+	// Need to send dates before 0001 A.D. with " BC" suffix, instead of the
+	// minus sign preferred by Go.
+	// Beware, "0000" in ISO is "1 BC", "-0001" is "2 BC" and so on
+	bc := false
+	if t.Year() <= 0 {
+		// flip year sign, and add 1, e.g: "0" will be "1", and "-10" will be "11"
+		t = t.AddDate((-t.Year())*2+1, 0, 0)
+		bc = true
+	}
+	b := []byte(t.Format("2006-01-02 15:04:05.999999999Z07:00"))
+
+	_, offset := t.Zone()
+	offset = offset % 60
+	if offset != 0 {
+		// RFC3339Nano already printed the minus sign
+		if offset < 0 {
+			offset = -offset
+		}
+
+		b = append(b, ':')
+		if offset < 10 {
+			b = append(b, '0')
+		}
+		b = strconv.AppendInt(b, int64(offset), 10)
+	}
+
+	if bc {
+		b = append(b, " BC"...)
+	}
+	return b
+}
+
+// Parse a bytea value received from the server.  Both "hex" and the legacy
+// "escape" format are supported.
+func parseBytea(s []byte) (result []byte, err error) {
+	if len(s) >= 2 && bytes.Equal(s[:2], []byte("\\x")) {
+		// bytea_output = hex
+		s = s[2:] // trim off leading "\\x"
+		result = make([]byte, hex.DecodedLen(len(s)))
+		_, err := hex.Decode(result, s)
+		if err != nil {
+			return nil, err
+		}
+	} else {
+		// bytea_output = escape
+		for len(s) > 0 {
+			if s[0] == '\\' {
+				// escaped '\\'
+				if len(s) >= 2 && s[1] == '\\' {
+					result = append(result, '\\')
+					s = s[2:]
+					continue
+				}
+
+				// '\\' followed by an octal number
+				if len(s) < 4 {
+					return nil, fmt.Errorf("invalid bytea sequence %v", s)
+				}
+				r, err := strconv.ParseInt(string(s[1:4]), 8, 9)
+				if err != nil {
+					return nil, fmt.Errorf("could not parse bytea value: %s", err.Error())
+				}
+				result = append(result, byte(r))
+				s = s[4:]
+			} else {
+				// We hit an unescaped, raw byte.  Try to read in as many as
+				// possible in one go.
+				i := bytes.IndexByte(s, '\\')
+				if i == -1 {
+					result = append(result, s...)
+					break
+				}
+				result = append(result, s[:i]...)
+				s = s[i:]
+			}
+		}
+	}
+
+	return result, nil
+}
+
+func encodeBytea(serverVersion int, v []byte) (result []byte) {
+	if serverVersion >= 90000 {
+		// Use the hex format if we know that the server supports it
+		result = make([]byte, 2+hex.EncodedLen(len(v)))
+		result[0] = '\\'
+		result[1] = 'x'
+		hex.Encode(result[2:], v)
+	} else {
+		// .. or resort to "escape"
+		for _, b := range v {
+			if b == '\\' {
+				result = append(result, '\\', '\\')
+			} else if b < 0x20 || b > 0x7e {
+				result = append(result, []byte(fmt.Sprintf("\\%03o", b))...)
+			} else {
+				result = append(result, b)
+			}
+		}
+	}
+
+	return result
+}
+
+// NullTime represents a time.Time that may be null. NullTime implements the
+// sql.Scanner interface so it can be used as a scan destination, similar to
+// sql.NullString.
+type NullTime struct {
+	Time  time.Time
+	Valid bool // Valid is true if Time is not NULL
+}
+
+// Scan implements the Scanner interface.
+func (nt *NullTime) Scan(value interface{}) error {
+	nt.Time, nt.Valid = value.(time.Time)
+	return nil
+}
+
+// Value implements the driver Valuer interface.
+func (nt NullTime) Value() (driver.Value, error) {
+	if !nt.Valid {
+		return nil, nil
+	}
+	return nt.Time, nil
+}


[5/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode_test.go
new file mode 100644
index 0000000..3a0f728
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/encode_test.go
@@ -0,0 +1,758 @@
+package pq
+
+import (
+	"bytes"
+	"database/sql"
+	"fmt"
+	"strings"
+	"testing"
+	"time"
+
+	"github.com/lib/pq/oid"
+)
+
+func TestScanTimestamp(t *testing.T) {
+	var nt NullTime
+	tn := time.Now()
+	nt.Scan(tn)
+	if !nt.Valid {
+		t.Errorf("Expected Valid=false")
+	}
+	if nt.Time != tn {
+		t.Errorf("Time value mismatch")
+	}
+}
+
+func TestScanNilTimestamp(t *testing.T) {
+	var nt NullTime
+	nt.Scan(nil)
+	if nt.Valid {
+		t.Errorf("Expected Valid=false")
+	}
+}
+
+var timeTests = []struct {
+	str     string
+	timeval time.Time
+}{
+	{"22001-02-03", time.Date(22001, time.February, 3, 0, 0, 0, 0, time.FixedZone("", 0))},
+	{"2001-02-03", time.Date(2001, time.February, 3, 0, 0, 0, 0, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06", time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.000001", time.Date(2001, time.February, 3, 4, 5, 6, 1000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.00001", time.Date(2001, time.February, 3, 4, 5, 6, 10000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.0001", time.Date(2001, time.February, 3, 4, 5, 6, 100000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.001", time.Date(2001, time.February, 3, 4, 5, 6, 1000000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.01", time.Date(2001, time.February, 3, 4, 5, 6, 10000000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.1", time.Date(2001, time.February, 3, 4, 5, 6, 100000000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.12", time.Date(2001, time.February, 3, 4, 5, 6, 120000000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.123", time.Date(2001, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.1234", time.Date(2001, time.February, 3, 4, 5, 6, 123400000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.12345", time.Date(2001, time.February, 3, 4, 5, 6, 123450000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.123456", time.Date(2001, time.February, 3, 4, 5, 6, 123456000, time.FixedZone("", 0))},
+	{"2001-02-03 04:05:06.123-07", time.Date(2001, time.February, 3, 4, 5, 6, 123000000,
+		time.FixedZone("", -7*60*60))},
+	{"2001-02-03 04:05:06-07", time.Date(2001, time.February, 3, 4, 5, 6, 0,
+		time.FixedZone("", -7*60*60))},
+	{"2001-02-03 04:05:06-07:42", time.Date(2001, time.February, 3, 4, 5, 6, 0,
+		time.FixedZone("", -(7*60*60+42*60)))},
+	{"2001-02-03 04:05:06-07:30:09", time.Date(2001, time.February, 3, 4, 5, 6, 0,
+		time.FixedZone("", -(7*60*60+30*60+9)))},
+	{"2001-02-03 04:05:06+07", time.Date(2001, time.February, 3, 4, 5, 6, 0,
+		time.FixedZone("", 7*60*60))},
+	{"0011-02-03 04:05:06 BC", time.Date(-10, time.February, 3, 4, 5, 6, 0, time.FixedZone("", 0))},
+	{"0011-02-03 04:05:06.123 BC", time.Date(-10, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", 0))},
+	{"0011-02-03 04:05:06.123-07 BC", time.Date(-10, time.February, 3, 4, 5, 6, 123000000,
+		time.FixedZone("", -7*60*60))},
+	{"0001-02-03 04:05:06.123", time.Date(1, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", 0))},
+	{"0001-02-03 04:05:06.123 BC", time.Date(1, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", 0)).AddDate(-1, 0, 0)},
+	{"0001-02-03 04:05:06.123 BC", time.Date(0, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", 0))},
+	{"0002-02-03 04:05:06.123 BC", time.Date(0, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", 0)).AddDate(-1, 0, 0)},
+	{"0002-02-03 04:05:06.123 BC", time.Date(-1, time.February, 3, 4, 5, 6, 123000000, time.FixedZone("", 0))},
+	{"12345-02-03 04:05:06.1", time.Date(12345, time.February, 3, 4, 5, 6, 100000000, time.FixedZone("", 0))},
+	{"123456-02-03 04:05:06.1", time.Date(123456, time.February, 3, 4, 5, 6, 100000000, time.FixedZone("", 0))},
+}
+
+// Test that parsing the string results in the expected value.
+func TestParseTs(t *testing.T) {
+	for i, tt := range timeTests {
+		val, err := ParseTimestamp(nil, tt.str)
+		if err != nil {
+			t.Errorf("%d: got error: %v", i, err)
+		} else if val.String() != tt.timeval.String() {
+			t.Errorf("%d: expected to parse %q into %q; got %q",
+				i, tt.str, tt.timeval, val)
+		}
+	}
+}
+
+var timeErrorTests = []string{
+	"2001",
+	"2001-2-03",
+	"2001-02-3",
+	"2001-02-03 ",
+	"2001-02-03 04",
+	"2001-02-03 04:",
+	"2001-02-03 04:05",
+	"2001-02-03 04:05:",
+	"2001-02-03 04:05:6",
+	"2001-02-03 04:05:06.123 B",
+}
+
+// Test that parsing the string results in an error.
+func TestParseTsErrors(t *testing.T) {
+	for i, tt := range timeErrorTests {
+		_, err := ParseTimestamp(nil, tt)
+		if err == nil {
+			t.Errorf("%d: expected an error from parsing: %v", i, tt)
+		}
+	}
+}
+
+// Now test that sending the value into the database and parsing it back
+// returns the same time.Time value.
+func TestEncodeAndParseTs(t *testing.T) {
+	db, err := openTestConnConninfo("timezone='Etc/UTC'")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer db.Close()
+
+	for i, tt := range timeTests {
+		var dbstr string
+		err = db.QueryRow("SELECT ($1::timestamptz)::text", tt.timeval).Scan(&dbstr)
+		if err != nil {
+			t.Errorf("%d: could not send value %q to the database: %s", i, tt.timeval, err)
+			continue
+		}
+
+		val, err := ParseTimestamp(nil, dbstr)
+		if err != nil {
+			t.Errorf("%d: could not parse value %q: %s", i, dbstr, err)
+			continue
+		}
+		val = val.In(tt.timeval.Location())
+		if val.String() != tt.timeval.String() {
+			t.Errorf("%d: expected to parse %q into %q; got %q", i, dbstr, tt.timeval, val)
+		}
+	}
+}
+
+var formatTimeTests = []struct {
+	time     time.Time
+	expected string
+}{
+	{time.Time{}, "0001-01-01 00:00:00Z"},
+	{time.Date(2001, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", 0)), "2001-02-03 04:05:06.123456789Z"},
+	{time.Date(2001, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", 2*60*60)), "2001-02-03 04:05:06.123456789+02:00"},
+	{time.Date(2001, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", -6*60*60)), "2001-02-03 04:05:06.123456789-06:00"},
+	{time.Date(2001, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -(7*60*60+30*60+9))), "2001-02-03 04:05:06-07:30:09"},
+
+	{time.Date(1, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", 0)), "0001-02-03 04:05:06.123456789Z"},
+	{time.Date(1, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", 2*60*60)), "0001-02-03 04:05:06.123456789+02:00"},
+	{time.Date(1, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", -6*60*60)), "0001-02-03 04:05:06.123456789-06:00"},
+
+	{time.Date(0, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", 0)), "0001-02-03 04:05:06.123456789Z BC"},
+	{time.Date(0, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", 2*60*60)), "0001-02-03 04:05:06.123456789+02:00 BC"},
+	{time.Date(0, time.February, 3, 4, 5, 6, 123456789, time.FixedZone("", -6*60*60)), "0001-02-03 04:05:06.123456789-06:00 BC"},
+
+	{time.Date(1, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -(7*60*60+30*60+9))), "0001-02-03 04:05:06-07:30:09"},
+	{time.Date(0, time.February, 3, 4, 5, 6, 0, time.FixedZone("", -(7*60*60+30*60+9))), "0001-02-03 04:05:06-07:30:09 BC"},
+}
+
+func TestFormatTs(t *testing.T) {
+	for i, tt := range formatTimeTests {
+		val := string(formatTs(tt.time))
+		if val != tt.expected {
+			t.Errorf("%d: incorrect time format %q, want %q", i, val, tt.expected)
+		}
+	}
+}
+
+func TestFormatTsBackend(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	var str string
+	err := db.QueryRow("SELECT '2001-02-03T04:05:06.007-08:09:10'::time::text").Scan(&str)
+	if err == nil {
+		t.Fatalf("PostgreSQL is accepting an ISO timestamp input for time")
+	}
+
+	for i, tt := range formatTimeTests {
+		for _, typ := range []string{"date", "time", "timetz", "timestamp", "timestamptz"} {
+			err = db.QueryRow("SELECT $1::"+typ+"::text", tt.time).Scan(&str)
+			if err != nil {
+				t.Errorf("%d: incorrect time format for %v on the backend: %v", i, typ, err)
+			}
+		}
+	}
+}
+
+func TestTimestampWithTimeZone(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	tx, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer tx.Rollback()
+
+	// try several different locations, all included in Go's zoneinfo.zip
+	for _, locName := range []string{
+		"UTC",
+		"America/Chicago",
+		"America/New_York",
+		"Australia/Darwin",
+		"Australia/Perth",
+	} {
+		loc, err := time.LoadLocation(locName)
+		if err != nil {
+			t.Logf("Could not load time zone %s - skipping", locName)
+			continue
+		}
+
+		// Postgres timestamps have a resolution of 1 microsecond, so don't
+		// use the full range of the Nanosecond argument
+		refTime := time.Date(2012, 11, 6, 10, 23, 42, 123456000, loc)
+
+		for _, pgTimeZone := range []string{"US/Eastern", "Australia/Darwin"} {
+			// Switch Postgres's timezone to test different output timestamp formats
+			_, err = tx.Exec(fmt.Sprintf("set time zone '%s'", pgTimeZone))
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			var gotTime time.Time
+			row := tx.QueryRow("select $1::timestamp with time zone", refTime)
+			err = row.Scan(&gotTime)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			if !refTime.Equal(gotTime) {
+				t.Errorf("timestamps not equal: %s != %s", refTime, gotTime)
+			}
+
+			// check that the time zone is set correctly based on TimeZone
+			pgLoc, err := time.LoadLocation(pgTimeZone)
+			if err != nil {
+				t.Logf("Could not load time zone %s - skipping", pgLoc)
+				continue
+			}
+			translated := refTime.In(pgLoc)
+			if translated.String() != gotTime.String() {
+				t.Errorf("timestamps not equal: %s != %s", translated, gotTime)
+			}
+		}
+	}
+}
+
+func TestTimestampWithOutTimezone(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	test := func(ts, pgts string) {
+		r, err := db.Query("SELECT $1::timestamp", pgts)
+		if err != nil {
+			t.Fatalf("Could not run query: %v", err)
+		}
+
+		n := r.Next()
+
+		if n != true {
+			t.Fatal("Expected at least one row")
+		}
+
+		var result time.Time
+		err = r.Scan(&result)
+		if err != nil {
+			t.Fatalf("Did not expect error scanning row: %v", err)
+		}
+
+		expected, err := time.Parse(time.RFC3339, ts)
+		if err != nil {
+			t.Fatalf("Could not parse test time literal: %v", err)
+		}
+
+		if !result.Equal(expected) {
+			t.Fatalf("Expected time to match %v: got mismatch %v",
+				expected, result)
+		}
+
+		n = r.Next()
+		if n != false {
+			t.Fatal("Expected only one row")
+		}
+	}
+
+	test("2000-01-01T00:00:00Z", "2000-01-01T00:00:00")
+
+	// Test higher precision time
+	test("2013-01-04T20:14:58.80033Z", "2013-01-04 20:14:58.80033")
+}
+
+func TestInfinityTimestamp(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+	var err error
+	var resultT time.Time
+
+	expectedErrorStrPrefix := `sql: Scan error on column index 0: unsupported`
+	type testCases []struct {
+		Query                string
+		Param                string
+		ExpectedErrStrPrefix string
+		ExpectedVal          interface{}
+	}
+	tc := testCases{
+		{"SELECT $1::timestamp", "-infinity", expectedErrorStrPrefix, "-infinity"},
+		{"SELECT $1::timestamptz", "-infinity", expectedErrorStrPrefix, "-infinity"},
+		{"SELECT $1::timestamp", "infinity", expectedErrorStrPrefix, "infinity"},
+		{"SELECT $1::timestamptz", "infinity", expectedErrorStrPrefix, "infinity"},
+	}
+	// try to assert []byte to time.Time
+	for _, q := range tc {
+		err = db.QueryRow(q.Query, q.Param).Scan(&resultT)
+		if !strings.HasPrefix(err.Error(), q.ExpectedErrStrPrefix) {
+			t.Errorf("Scanning -/+infinity, expected error to have prefix %q, got %q", q.ExpectedErrStrPrefix, err)
+		}
+	}
+	// yield []byte
+	for _, q := range tc {
+		var resultI interface{}
+		err = db.QueryRow(q.Query, q.Param).Scan(&resultI)
+		if err != nil {
+			t.Errorf("Scanning -/+infinity, expected no error, got %q", err)
+		}
+		result, ok := resultI.([]byte)
+		if !ok {
+			t.Errorf("Scanning -/+infinity, expected []byte, got %#v", resultI)
+		}
+		if string(result) != q.ExpectedVal {
+			t.Errorf("Scanning -/+infinity, expected %q, got %q", q.ExpectedVal, result)
+		}
+	}
+
+	y1500 := time.Date(1500, time.January, 1, 0, 0, 0, 0, time.UTC)
+	y2500 := time.Date(2500, time.January, 1, 0, 0, 0, 0, time.UTC)
+	EnableInfinityTs(y1500, y2500)
+
+	err = db.QueryRow("SELECT $1::timestamp", "infinity").Scan(&resultT)
+	if err != nil {
+		t.Errorf("Scanning infinity, expected no error, got %q", err)
+	}
+	if !resultT.Equal(y2500) {
+		t.Errorf("Scanning infinity, expected %q, got %q", y2500, resultT)
+	}
+
+	err = db.QueryRow("SELECT $1::timestamptz", "infinity").Scan(&resultT)
+	if err != nil {
+		t.Errorf("Scanning infinity, expected no error, got %q", err)
+	}
+	if !resultT.Equal(y2500) {
+		t.Errorf("Scanning Infinity, expected time %q, got %q", y2500, resultT.String())
+	}
+
+	err = db.QueryRow("SELECT $1::timestamp", "-infinity").Scan(&resultT)
+	if err != nil {
+		t.Errorf("Scanning -infinity, expected no error, got %q", err)
+	}
+	if !resultT.Equal(y1500) {
+		t.Errorf("Scanning -infinity, expected time %q, got %q", y1500, resultT.String())
+	}
+
+	err = db.QueryRow("SELECT $1::timestamptz", "-infinity").Scan(&resultT)
+	if err != nil {
+		t.Errorf("Scanning -infinity, expected no error, got %q", err)
+	}
+	if !resultT.Equal(y1500) {
+		t.Errorf("Scanning -infinity, expected time %q, got %q", y1500, resultT.String())
+	}
+
+	ym1500 := time.Date(-1500, time.January, 1, 0, 0, 0, 0, time.UTC)
+	y11500 := time.Date(11500, time.January, 1, 0, 0, 0, 0, time.UTC)
+	var s string
+	err = db.QueryRow("SELECT $1::timestamp::text", ym1500).Scan(&s)
+	if err != nil {
+		t.Errorf("Encoding -infinity, expected no error, got %q", err)
+	}
+	if s != "-infinity" {
+		t.Errorf("Encoding -infinity, expected %q, got %q", "-infinity", s)
+	}
+	err = db.QueryRow("SELECT $1::timestamptz::text", ym1500).Scan(&s)
+	if err != nil {
+		t.Errorf("Encoding -infinity, expected no error, got %q", err)
+	}
+	if s != "-infinity" {
+		t.Errorf("Encoding -infinity, expected %q, got %q", "-infinity", s)
+	}
+
+	err = db.QueryRow("SELECT $1::timestamp::text", y11500).Scan(&s)
+	if err != nil {
+		t.Errorf("Encoding infinity, expected no error, got %q", err)
+	}
+	if s != "infinity" {
+		t.Errorf("Encoding infinity, expected %q, got %q", "infinity", s)
+	}
+	err = db.QueryRow("SELECT $1::timestamptz::text", y11500).Scan(&s)
+	if err != nil {
+		t.Errorf("Encoding infinity, expected no error, got %q", err)
+	}
+	if s != "infinity" {
+		t.Errorf("Encoding infinity, expected %q, got %q", "infinity", s)
+	}
+
+	disableInfinityTs()
+
+	var panicErrorString string
+	func() {
+		defer func() {
+			panicErrorString, _ = recover().(string)
+		}()
+		EnableInfinityTs(y2500, y1500)
+	}()
+	if panicErrorString != infinityTsNegativeMustBeSmaller {
+		t.Errorf("Expected error, %q, got %q", infinityTsNegativeMustBeSmaller, panicErrorString)
+	}
+}
+
+func TestStringWithNul(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	hello0world := string("hello\x00world")
+	_, err := db.Query("SELECT $1::text", &hello0world)
+	if err == nil {
+		t.Fatal("Postgres accepts a string with nul in it; " +
+			"injection attacks may be plausible")
+	}
+}
+
+func TestByteSliceToText(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	b := []byte("hello world")
+	row := db.QueryRow("SELECT $1::text", b)
+
+	var result []byte
+	err := row.Scan(&result)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if string(result) != string(b) {
+		t.Fatalf("expected %v but got %v", b, result)
+	}
+}
+
+func TestStringToBytea(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	b := "hello world"
+	row := db.QueryRow("SELECT $1::bytea", b)
+
+	var result []byte
+	err := row.Scan(&result)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if !bytes.Equal(result, []byte(b)) {
+		t.Fatalf("expected %v but got %v", b, result)
+	}
+}
+
+func TestTextByteSliceToUUID(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	b := []byte("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11")
+	row := db.QueryRow("SELECT $1::uuid", b)
+
+	var result string
+	err := row.Scan(&result)
+	if forceBinaryParameters() {
+		pqErr := err.(*Error)
+		if pqErr == nil {
+			t.Errorf("Expected to get error")
+		} else if pqErr.Code != "22P03" {
+			t.Fatalf("Expected to get invalid binary encoding error (22P03), got %s", pqErr.Code)
+		}
+	} else {
+		if err != nil {
+			t.Fatal(err)
+		}
+
+		if result != string(b) {
+			t.Fatalf("expected %v but got %v", b, result)
+		}
+	}
+}
+
+func TestBinaryByteSlicetoUUID(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	b := []byte{'\xa0', '\xee', '\xbc', '\x99',
+		'\x9c', '\x0b',
+		'\x4e', '\xf8',
+		'\xbb', '\x00', '\x6b',
+		'\xb9', '\xbd', '\x38', '\x0a', '\x11'}
+	row := db.QueryRow("SELECT $1::uuid", b)
+
+	var result string
+	err := row.Scan(&result)
+	if forceBinaryParameters() {
+		if err != nil {
+			t.Fatal(err)
+		}
+
+		if result != string("a0eebc99-9c0b-4ef8-bb00-6bb9bd380a11") {
+			t.Fatalf("expected %v but got %v", b, result)
+		}
+	} else {
+		pqErr := err.(*Error)
+		if pqErr == nil {
+			t.Errorf("Expected to get error")
+		} else if pqErr.Code != "22021" {
+			t.Fatalf("Expected to get invalid byte sequence for encoding error (22021), got %s", pqErr.Code)
+		}
+	}
+}
+
+func TestStringToUUID(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	s := "a0eebc99-9c0b-4ef8-bb00-6bb9bd380a11"
+	row := db.QueryRow("SELECT $1::uuid", s)
+
+	var result string
+	err := row.Scan(&result)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if result != s {
+		t.Fatalf("expected %v but got %v", s, result)
+	}
+}
+
+func TestTextByteSliceToInt(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	expected := 12345678
+	b := []byte(fmt.Sprintf("%d", expected))
+	row := db.QueryRow("SELECT $1::int", b)
+
+	var result int
+	err := row.Scan(&result)
+	if forceBinaryParameters() {
+		pqErr := err.(*Error)
+		if pqErr == nil {
+			t.Errorf("Expected to get error")
+		} else if pqErr.Code != "22P03" {
+			t.Fatalf("Expected to get invalid binary encoding error (22P03), got %s", pqErr.Code)
+		}
+	} else {
+		if err != nil {
+			t.Fatal(err)
+		}
+		if result != expected {
+			t.Fatalf("expected %v but got %v", expected, result)
+		}
+	}
+}
+
+func TestBinaryByteSliceToInt(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	expected := 12345678
+	b := []byte{'\x00', '\xbc', '\x61', '\x4e'}
+	row := db.QueryRow("SELECT $1::int", b)
+
+	var result int
+	err := row.Scan(&result)
+	if forceBinaryParameters() {
+		if err != nil {
+			t.Fatal(err)
+		}
+		if result != expected {
+			t.Fatalf("expected %v but got %v", expected, result)
+		}
+	} else {
+		pqErr := err.(*Error)
+		if pqErr == nil {
+			t.Errorf("Expected to get error")
+		} else if pqErr.Code != "22021" {
+			t.Fatalf("Expected to get invalid byte sequence for encoding error (22021), got %s", pqErr.Code)
+		}
+	}
+}
+
+func TestTextDecodeIntoString(t *testing.T) {
+	input := []byte("hello world")
+	want := string(input)
+	for _, typ := range []oid.Oid{oid.T_char, oid.T_varchar, oid.T_text} {
+		got := decode(&parameterStatus{}, input, typ, formatText)
+		if got != want {
+			t.Errorf("invalid string decoding output for %T(%+v), got %v but expected %v", typ, typ, got, want)
+		}
+	}
+}
+
+func TestByteaOutputFormatEncoding(t *testing.T) {
+	input := []byte("\\x\x00\x01\x02\xFF\xFEabcdefg0123")
+	want := []byte("\\x5c78000102fffe6162636465666730313233")
+	got := encode(&parameterStatus{serverVersion: 90000}, input, oid.T_bytea)
+	if !bytes.Equal(want, got) {
+		t.Errorf("invalid hex bytea output, got %v but expected %v", got, want)
+	}
+
+	want = []byte("\\\\x\\000\\001\\002\\377\\376abcdefg0123")
+	got = encode(&parameterStatus{serverVersion: 84000}, input, oid.T_bytea)
+	if !bytes.Equal(want, got) {
+		t.Errorf("invalid escape bytea output, got %v but expected %v", got, want)
+	}
+}
+
+func TestByteaOutputFormats(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	if getServerVersion(t, db) < 90000 {
+		// skip
+		return
+	}
+
+	testByteaOutputFormat := func(f string, usePrepared bool) {
+		expectedData := []byte("\x5c\x78\x00\xff\x61\x62\x63\x01\x08")
+		sqlQuery := "SELECT decode('5c7800ff6162630108', 'hex')"
+
+		var data []byte
+
+		// use a txn to avoid relying on getting the same connection
+		txn, err := db.Begin()
+		if err != nil {
+			t.Fatal(err)
+		}
+		defer txn.Rollback()
+
+		_, err = txn.Exec("SET LOCAL bytea_output TO " + f)
+		if err != nil {
+			t.Fatal(err)
+		}
+		var rows *sql.Rows
+		var stmt *sql.Stmt
+		if usePrepared {
+			stmt, err = txn.Prepare(sqlQuery)
+			if err != nil {
+				t.Fatal(err)
+			}
+			rows, err = stmt.Query()
+		} else {
+			// use Query; QueryRow would hide the actual error
+			rows, err = txn.Query(sqlQuery)
+		}
+		if err != nil {
+			t.Fatal(err)
+		}
+		if !rows.Next() {
+			if rows.Err() != nil {
+				t.Fatal(rows.Err())
+			}
+			t.Fatal("shouldn't happen")
+		}
+		err = rows.Scan(&data)
+		if err != nil {
+			t.Fatal(err)
+		}
+		err = rows.Close()
+		if err != nil {
+			t.Fatal(err)
+		}
+		if stmt != nil {
+			err = stmt.Close()
+			if err != nil {
+				t.Fatal(err)
+			}
+		}
+		if !bytes.Equal(data, expectedData) {
+			t.Errorf("unexpected bytea value %v for format %s; expected %v", data, f, expectedData)
+		}
+	}
+
+	testByteaOutputFormat("hex", false)
+	testByteaOutputFormat("escape", false)
+	testByteaOutputFormat("hex", true)
+	testByteaOutputFormat("escape", true)
+}
+
+func TestAppendEncodedText(t *testing.T) {
+	var buf []byte
+
+	buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, int64(10))
+	buf = append(buf, '\t')
+	buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, 42.0000000001)
+	buf = append(buf, '\t')
+	buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, "hello\tworld")
+	buf = append(buf, '\t')
+	buf = appendEncodedText(&parameterStatus{serverVersion: 90000}, buf, []byte{0, 128, 255})
+
+	if string(buf) != "10\t42.0000000001\thello\\tworld\t\\\\x0080ff" {
+		t.Fatal(string(buf))
+	}
+}
+
+func TestAppendEscapedText(t *testing.T) {
+	if esc := appendEscapedText(nil, "hallo\tescape"); string(esc) != "hallo\\tescape" {
+		t.Fatal(string(esc))
+	}
+	if esc := appendEscapedText(nil, "hallo\\tescape\n"); string(esc) != "hallo\\\\tescape\\n" {
+		t.Fatal(string(esc))
+	}
+	if esc := appendEscapedText(nil, "\n\r\t\f"); string(esc) != "\\n\\r\\t\f" {
+		t.Fatal(string(esc))
+	}
+}
+
+func TestAppendEscapedTextExistingBuffer(t *testing.T) {
+	var buf []byte
+	buf = []byte("123\t")
+	if esc := appendEscapedText(buf, "hallo\tescape"); string(esc) != "123\thallo\\tescape" {
+		t.Fatal(string(esc))
+	}
+	buf = []byte("123\t")
+	if esc := appendEscapedText(buf, "hallo\\tescape\n"); string(esc) != "123\thallo\\\\tescape\\n" {
+		t.Fatal(string(esc))
+	}
+	buf = []byte("123\t")
+	if esc := appendEscapedText(buf, "\n\r\t\f"); string(esc) != "123\t\\n\\r\\t\f" {
+		t.Fatal(string(esc))
+	}
+}
+
+func BenchmarkAppendEscapedText(b *testing.B) {
+	longString := ""
+	for i := 0; i < 100; i++ {
+		longString += "123456789\n"
+	}
+	for i := 0; i < b.N; i++ {
+		appendEscapedText(nil, longString)
+	}
+}
+
+func BenchmarkAppendEscapedTextNoEscape(b *testing.B) {
+	longString := ""
+	for i := 0; i < 100; i++ {
+		longString += "1234567890"
+	}
+	for i := 0; i < b.N; i++ {
+		appendEscapedText(nil, longString)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/error.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/error.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/error.go
new file mode 100644
index 0000000..b4bb44c
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/error.go
@@ -0,0 +1,508 @@
+package pq
+
+import (
+	"database/sql/driver"
+	"fmt"
+	"io"
+	"net"
+	"runtime"
+)
+
+// Error severities
+const (
+	Efatal   = "FATAL"
+	Epanic   = "PANIC"
+	Ewarning = "WARNING"
+	Enotice  = "NOTICE"
+	Edebug   = "DEBUG"
+	Einfo    = "INFO"
+	Elog     = "LOG"
+)
+
+// Error represents an error communicating with the server.
+//
+// See http://www.postgresql.org/docs/current/static/protocol-error-fields.html for details of the fields
+type Error struct {
+	Severity         string
+	Code             ErrorCode
+	Message          string
+	Detail           string
+	Hint             string
+	Position         string
+	InternalPosition string
+	InternalQuery    string
+	Where            string
+	Schema           string
+	Table            string
+	Column           string
+	DataTypeName     string
+	Constraint       string
+	File             string
+	Line             string
+	Routine          string
+}
+
+// ErrorCode is a five-character error code.
+type ErrorCode string
+
+// Name returns a more human friendly rendering of the error code, namely the
+// "condition name".
+//
+// See http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html for
+// details.
+func (ec ErrorCode) Name() string {
+	return errorCodeNames[ec]
+}
+
+// ErrorClass is only the class part of an error code.
+type ErrorClass string
+
+// Name returns the condition name of an error class.  It is equivalent to the
+// condition name of the "standard" error code (i.e. the one having the last
+// three characters "000").
+func (ec ErrorClass) Name() string {
+	return errorCodeNames[ErrorCode(ec+"000")]
+}
+
+// Class returns the error class, e.g. "28".
+//
+// See http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html for
+// details.
+func (ec ErrorCode) Class() ErrorClass {
+	return ErrorClass(ec[0:2])
+}
+
+// errorCodeNames is a mapping between the five-character error codes and the
+// human readable "condition names". It is derived from the list at
+// http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html
+var errorCodeNames = map[ErrorCode]string{
+	// Class 00 - Successful Completion
+	"00000": "successful_completion",
+	// Class 01 - Warning
+	"01000": "warning",
+	"0100C": "dynamic_result_sets_returned",
+	"01008": "implicit_zero_bit_padding",
+	"01003": "null_value_eliminated_in_set_function",
+	"01007": "privilege_not_granted",
+	"01006": "privilege_not_revoked",
+	"01004": "string_data_right_truncation",
+	"01P01": "deprecated_feature",
+	// Class 02 - No Data (this is also a warning class per the SQL standard)
+	"02000": "no_data",
+	"02001": "no_additional_dynamic_result_sets_returned",
+	// Class 03 - SQL Statement Not Yet Complete
+	"03000": "sql_statement_not_yet_complete",
+	// Class 08 - Connection Exception
+	"08000": "connection_exception",
+	"08003": "connection_does_not_exist",
+	"08006": "connection_failure",
+	"08001": "sqlclient_unable_to_establish_sqlconnection",
+	"08004": "sqlserver_rejected_establishment_of_sqlconnection",
+	"08007": "transaction_resolution_unknown",
+	"08P01": "protocol_violation",
+	// Class 09 - Triggered Action Exception
+	"09000": "triggered_action_exception",
+	// Class 0A - Feature Not Supported
+	"0A000": "feature_not_supported",
+	// Class 0B - Invalid Transaction Initiation
+	"0B000": "invalid_transaction_initiation",
+	// Class 0F - Locator Exception
+	"0F000": "locator_exception",
+	"0F001": "invalid_locator_specification",
+	// Class 0L - Invalid Grantor
+	"0L000": "invalid_grantor",
+	"0LP01": "invalid_grant_operation",
+	// Class 0P - Invalid Role Specification
+	"0P000": "invalid_role_specification",
+	// Class 0Z - Diagnostics Exception
+	"0Z000": "diagnostics_exception",
+	"0Z002": "stacked_diagnostics_accessed_without_active_handler",
+	// Class 20 - Case Not Found
+	"20000": "case_not_found",
+	// Class 21 - Cardinality Violation
+	"21000": "cardinality_violation",
+	// Class 22 - Data Exception
+	"22000": "data_exception",
+	"2202E": "array_subscript_error",
+	"22021": "character_not_in_repertoire",
+	"22008": "datetime_field_overflow",
+	"22012": "division_by_zero",
+	"22005": "error_in_assignment",
+	"2200B": "escape_character_conflict",
+	"22022": "indicator_overflow",
+	"22015": "interval_field_overflow",
+	"2201E": "invalid_argument_for_logarithm",
+	"22014": "invalid_argument_for_ntile_function",
+	"22016": "invalid_argument_for_nth_value_function",
+	"2201F": "invalid_argument_for_power_function",
+	"2201G": "invalid_argument_for_width_bucket_function",
+	"22018": "invalid_character_value_for_cast",
+	"22007": "invalid_datetime_format",
+	"22019": "invalid_escape_character",
+	"2200D": "invalid_escape_octet",
+	"22025": "invalid_escape_sequence",
+	"22P06": "nonstandard_use_of_escape_character",
+	"22010": "invalid_indicator_parameter_value",
+	"22023": "invalid_parameter_value",
+	"2201B": "invalid_regular_expression",
+	"2201W": "invalid_row_count_in_limit_clause",
+	"2201X": "invalid_row_count_in_result_offset_clause",
+	"22009": "invalid_time_zone_displacement_value",
+	"2200C": "invalid_use_of_escape_character",
+	"2200G": "most_specific_type_mismatch",
+	"22004": "null_value_not_allowed",
+	"22002": "null_value_no_indicator_parameter",
+	"22003": "numeric_value_out_of_range",
+	"22026": "string_data_length_mismatch",
+	"22001": "string_data_right_truncation",
+	"22011": "substring_error",
+	"22027": "trim_error",
+	"22024": "unterminated_c_string",
+	"2200F": "zero_length_character_string",
+	"22P01": "floating_point_exception",
+	"22P02": "invalid_text_representation",
+	"22P03": "invalid_binary_representation",
+	"22P04": "bad_copy_file_format",
+	"22P05": "untranslatable_character",
+	"2200L": "not_an_xml_document",
+	"2200M": "invalid_xml_document",
+	"2200N": "invalid_xml_content",
+	"2200S": "invalid_xml_comment",
+	"2200T": "invalid_xml_processing_instruction",
+	// Class 23 - Integrity Constraint Violation
+	"23000": "integrity_constraint_violation",
+	"23001": "restrict_violation",
+	"23502": "not_null_violation",
+	"23503": "foreign_key_violation",
+	"23505": "unique_violation",
+	"23514": "check_violation",
+	"23P01": "exclusion_violation",
+	// Class 24 - Invalid Cursor State
+	"24000": "invalid_cursor_state",
+	// Class 25 - Invalid Transaction State
+	"25000": "invalid_transaction_state",
+	"25001": "active_sql_transaction",
+	"25002": "branch_transaction_already_active",
+	"25008": "held_cursor_requires_same_isolation_level",
+	"25003": "inappropriate_access_mode_for_branch_transaction",
+	"25004": "inappropriate_isolation_level_for_branch_transaction",
+	"25005": "no_active_sql_transaction_for_branch_transaction",
+	"25006": "read_only_sql_transaction",
+	"25007": "schema_and_data_statement_mixing_not_supported",
+	"25P01": "no_active_sql_transaction",
+	"25P02": "in_failed_sql_transaction",
+	// Class 26 - Invalid SQL Statement Name
+	"26000": "invalid_sql_statement_name",
+	// Class 27 - Triggered Data Change Violation
+	"27000": "triggered_data_change_violation",
+	// Class 28 - Invalid Authorization Specification
+	"28000": "invalid_authorization_specification",
+	"28P01": "invalid_password",
+	// Class 2B - Dependent Privilege Descriptors Still Exist
+	"2B000": "dependent_privilege_descriptors_still_exist",
+	"2BP01": "dependent_objects_still_exist",
+	// Class 2D - Invalid Transaction Termination
+	"2D000": "invalid_transaction_termination",
+	// Class 2F - SQL Routine Exception
+	"2F000": "sql_routine_exception",
+	"2F005": "function_executed_no_return_statement",
+	"2F002": "modifying_sql_data_not_permitted",
+	"2F003": "prohibited_sql_statement_attempted",
+	"2F004": "reading_sql_data_not_permitted",
+	// Class 34 - Invalid Cursor Name
+	"34000": "invalid_cursor_name",
+	// Class 38 - External Routine Exception
+	"38000": "external_routine_exception",
+	"38001": "containing_sql_not_permitted",
+	"38002": "modifying_sql_data_not_permitted",
+	"38003": "prohibited_sql_statement_attempted",
+	"38004": "reading_sql_data_not_permitted",
+	// Class 39 - External Routine Invocation Exception
+	"39000": "external_routine_invocation_exception",
+	"39001": "invalid_sqlstate_returned",
+	"39004": "null_value_not_allowed",
+	"39P01": "trigger_protocol_violated",
+	"39P02": "srf_protocol_violated",
+	// Class 3B - Savepoint Exception
+	"3B000": "savepoint_exception",
+	"3B001": "invalid_savepoint_specification",
+	// Class 3D - Invalid Catalog Name
+	"3D000": "invalid_catalog_name",
+	// Class 3F - Invalid Schema Name
+	"3F000": "invalid_schema_name",
+	// Class 40 - Transaction Rollback
+	"40000": "transaction_rollback",
+	"40002": "transaction_integrity_constraint_violation",
+	"40001": "serialization_failure",
+	"40003": "statement_completion_unknown",
+	"40P01": "deadlock_detected",
+	// Class 42 - Syntax Error or Access Rule Violation
+	"42000": "syntax_error_or_access_rule_violation",
+	"42601": "syntax_error",
+	"42501": "insufficient_privilege",
+	"42846": "cannot_coerce",
+	"42803": "grouping_error",
+	"42P20": "windowing_error",
+	"42P19": "invalid_recursion",
+	"42830": "invalid_foreign_key",
+	"42602": "invalid_name",
+	"42622": "name_too_long",
+	"42939": "reserved_name",
+	"42804": "datatype_mismatch",
+	"42P18": "indeterminate_datatype",
+	"42P21": "collation_mismatch",
+	"42P22": "indeterminate_collation",
+	"42809": "wrong_object_type",
+	"42703": "undefined_column",
+	"42883": "undefined_function",
+	"42P01": "undefined_table",
+	"42P02": "undefined_parameter",
+	"42704": "undefined_object",
+	"42701": "duplicate_column",
+	"42P03": "duplicate_cursor",
+	"42P04": "duplicate_database",
+	"42723": "duplicate_function",
+	"42P05": "duplicate_prepared_statement",
+	"42P06": "duplicate_schema",
+	"42P07": "duplicate_table",
+	"42712": "duplicate_alias",
+	"42710": "duplicate_object",
+	"42702": "ambiguous_column",
+	"42725": "ambiguous_function",
+	"42P08": "ambiguous_parameter",
+	"42P09": "ambiguous_alias",
+	"42P10": "invalid_column_reference",
+	"42611": "invalid_column_definition",
+	"42P11": "invalid_cursor_definition",
+	"42P12": "invalid_database_definition",
+	"42P13": "invalid_function_definition",
+	"42P14": "invalid_prepared_statement_definition",
+	"42P15": "invalid_schema_definition",
+	"42P16": "invalid_table_definition",
+	"42P17": "invalid_object_definition",
+	// Class 44 - WITH CHECK OPTION Violation
+	"44000": "with_check_option_violation",
+	// Class 53 - Insufficient Resources
+	"53000": "insufficient_resources",
+	"53100": "disk_full",
+	"53200": "out_of_memory",
+	"53300": "too_many_connections",
+	"53400": "configuration_limit_exceeded",
+	// Class 54 - Program Limit Exceeded
+	"54000": "program_limit_exceeded",
+	"54001": "statement_too_complex",
+	"54011": "too_many_columns",
+	"54023": "too_many_arguments",
+	// Class 55 - Object Not In Prerequisite State
+	"55000": "object_not_in_prerequisite_state",
+	"55006": "object_in_use",
+	"55P02": "cant_change_runtime_param",
+	"55P03": "lock_not_available",
+	// Class 57 - Operator Intervention
+	"57000": "operator_intervention",
+	"57014": "query_canceled",
+	"57P01": "admin_shutdown",
+	"57P02": "crash_shutdown",
+	"57P03": "cannot_connect_now",
+	"57P04": "database_dropped",
+	// Class 58 - System Error (errors external to PostgreSQL itself)
+	"58000": "system_error",
+	"58030": "io_error",
+	"58P01": "undefined_file",
+	"58P02": "duplicate_file",
+	// Class F0 - Configuration File Error
+	"F0000": "config_file_error",
+	"F0001": "lock_file_exists",
+	// Class HV - Foreign Data Wrapper Error (SQL/MED)
+	"HV000": "fdw_error",
+	"HV005": "fdw_column_name_not_found",
+	"HV002": "fdw_dynamic_parameter_value_needed",
+	"HV010": "fdw_function_sequence_error",
+	"HV021": "fdw_inconsistent_descriptor_information",
+	"HV024": "fdw_invalid_attribute_value",
+	"HV007": "fdw_invalid_column_name",
+	"HV008": "fdw_invalid_column_number",
+	"HV004": "fdw_invalid_data_type",
+	"HV006": "fdw_invalid_data_type_descriptors",
+	"HV091": "fdw_invalid_descriptor_field_identifier",
+	"HV00B": "fdw_invalid_handle",
+	"HV00C": "fdw_invalid_option_index",
+	"HV00D": "fdw_invalid_option_name",
+	"HV090": "fdw_invalid_string_length_or_buffer_length",
+	"HV00A": "fdw_invalid_string_format",
+	"HV009": "fdw_invalid_use_of_null_pointer",
+	"HV014": "fdw_too_many_handles",
+	"HV001": "fdw_out_of_memory",
+	"HV00P": "fdw_no_schemas",
+	"HV00J": "fdw_option_name_not_found",
+	"HV00K": "fdw_reply_handle",
+	"HV00Q": "fdw_schema_not_found",
+	"HV00R": "fdw_table_not_found",
+	"HV00L": "fdw_unable_to_create_execution",
+	"HV00M": "fdw_unable_to_create_reply",
+	"HV00N": "fdw_unable_to_establish_connection",
+	// Class P0 - PL/pgSQL Error
+	"P0000": "plpgsql_error",
+	"P0001": "raise_exception",
+	"P0002": "no_data_found",
+	"P0003": "too_many_rows",
+	// Class XX - Internal Error
+	"XX000": "internal_error",
+	"XX001": "data_corrupted",
+	"XX002": "index_corrupted",
+}
+
+func parseError(r *readBuf) *Error {
+	err := new(Error)
+	for t := r.byte(); t != 0; t = r.byte() {
+		msg := r.string()
+		switch t {
+		case 'S':
+			err.Severity = msg
+		case 'C':
+			err.Code = ErrorCode(msg)
+		case 'M':
+			err.Message = msg
+		case 'D':
+			err.Detail = msg
+		case 'H':
+			err.Hint = msg
+		case 'P':
+			err.Position = msg
+		case 'p':
+			err.InternalPosition = msg
+		case 'q':
+			err.InternalQuery = msg
+		case 'W':
+			err.Where = msg
+		case 's':
+			err.Schema = msg
+		case 't':
+			err.Table = msg
+		case 'c':
+			err.Column = msg
+		case 'd':
+			err.DataTypeName = msg
+		case 'n':
+			err.Constraint = msg
+		case 'F':
+			err.File = msg
+		case 'L':
+			err.Line = msg
+		case 'R':
+			err.Routine = msg
+		}
+	}
+	return err
+}
+
+// Fatal returns true if the Error Severity is fatal.
+func (err *Error) Fatal() bool {
+	return err.Severity == Efatal
+}
+
+// Get implements the legacy PGError interface. New code should use the fields
+// of the Error struct directly.
+func (err *Error) Get(k byte) (v string) {
+	switch k {
+	case 'S':
+		return err.Severity
+	case 'C':
+		return string(err.Code)
+	case 'M':
+		return err.Message
+	case 'D':
+		return err.Detail
+	case 'H':
+		return err.Hint
+	case 'P':
+		return err.Position
+	case 'p':
+		return err.InternalPosition
+	case 'q':
+		return err.InternalQuery
+	case 'W':
+		return err.Where
+	case 's':
+		return err.Schema
+	case 't':
+		return err.Table
+	case 'c':
+		return err.Column
+	case 'd':
+		return err.DataTypeName
+	case 'n':
+		return err.Constraint
+	case 'F':
+		return err.File
+	case 'L':
+		return err.Line
+	case 'R':
+		return err.Routine
+	}
+	return ""
+}
+
+func (err Error) Error() string {
+	return "pq: " + err.Message
+}
+
+// PGError is an interface used by previous versions of pq. It is provided
+// only to support legacy code. New code should use the Error type.
+type PGError interface {
+	Error() string
+	Fatal() bool
+	Get(k byte) (v string)
+}
+
+func errorf(s string, args ...interface{}) {
+	panic(fmt.Errorf("pq: %s", fmt.Sprintf(s, args...)))
+}
+
+func errRecoverNoErrBadConn(err *error) {
+	e := recover()
+	if e == nil {
+		// Do nothing
+		return
+	}
+	var ok bool
+	*err, ok = e.(error)
+	if !ok {
+		*err = fmt.Errorf("pq: unexpected error: %#v", e)
+	}
+}
+
+func (c *conn) errRecover(err *error) {
+	e := recover()
+	switch v := e.(type) {
+	case nil:
+		// Do nothing
+	case runtime.Error:
+		c.bad = true
+		panic(v)
+	case *Error:
+		if v.Fatal() {
+			*err = driver.ErrBadConn
+		} else {
+			*err = v
+		}
+	case *net.OpError:
+		*err = driver.ErrBadConn
+	case error:
+		if v == io.EOF || v.(error).Error() == "remote error: handshake failure" {
+			*err = driver.ErrBadConn
+		} else {
+			*err = v
+		}
+
+	default:
+		c.bad = true
+		panic(fmt.Sprintf("unknown error: %#v", e))
+	}
+
+	// Any time we return ErrBadConn, we need to remember it since *Tx doesn't
+	// mark the connection bad in database/sql.
+	if *err == driver.ErrBadConn {
+		c.bad = true
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/go18_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/go18_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/go18_test.go
new file mode 100644
index 0000000..4bf6391
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/go18_test.go
@@ -0,0 +1,319 @@
+// +build go1.8
+
+package pq
+
+import (
+	"context"
+	"database/sql"
+	"runtime"
+	"strings"
+	"testing"
+	"time"
+)
+
+func TestMultipleSimpleQuery(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	rows, err := db.Query("select 1; set time zone default; select 2; select 3")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer rows.Close()
+
+	var i int
+	for rows.Next() {
+		if err := rows.Scan(&i); err != nil {
+			t.Fatal(err)
+		}
+		if i != 1 {
+			t.Fatalf("expected 1, got %d", i)
+		}
+	}
+	if !rows.NextResultSet() {
+		t.Fatal("expected more result sets", rows.Err())
+	}
+	for rows.Next() {
+		if err := rows.Scan(&i); err != nil {
+			t.Fatal(err)
+		}
+		if i != 2 {
+			t.Fatalf("expected 2, got %d", i)
+		}
+	}
+
+	// Make sure that if we ignore a result we can still query.
+
+	rows, err = db.Query("select 4; select 5")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer rows.Close()
+
+	for rows.Next() {
+		if err := rows.Scan(&i); err != nil {
+			t.Fatal(err)
+		}
+		if i != 4 {
+			t.Fatalf("expected 4, got %d", i)
+		}
+	}
+	if !rows.NextResultSet() {
+		t.Fatal("expected more result sets", rows.Err())
+	}
+	for rows.Next() {
+		if err := rows.Scan(&i); err != nil {
+			t.Fatal(err)
+		}
+		if i != 5 {
+			t.Fatalf("expected 5, got %d", i)
+		}
+	}
+	if rows.NextResultSet() {
+		t.Fatal("unexpected result set")
+	}
+}
+
+const contextRaceIterations = 100
+
+func TestContextCancelExec(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	// Delay execution for just a bit until db.ExecContext has begun.
+	defer time.AfterFunc(time.Millisecond*10, cancel).Stop()
+
+	// Not canceled until after the exec has started.
+	if _, err := db.ExecContext(ctx, "select pg_sleep(1)"); err == nil {
+		t.Fatal("expected error")
+	} else if err.Error() != "pq: canceling statement due to user request" {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	// Context is already canceled, so error should come before execution.
+	if _, err := db.ExecContext(ctx, "select pg_sleep(1)"); err == nil {
+		t.Fatal("expected error")
+	} else if err.Error() != "context canceled" {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	for i := 0; i < contextRaceIterations; i++ {
+		func() {
+			ctx, cancel := context.WithCancel(context.Background())
+			defer cancel()
+			if _, err := db.ExecContext(ctx, "select 1"); err != nil {
+				t.Fatal(err)
+			}
+		}()
+
+		if _, err := db.Exec("select 1"); err != nil {
+			t.Fatal(err)
+		}
+	}
+}
+
+func TestContextCancelQuery(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	ctx, cancel := context.WithCancel(context.Background())
+
+	// Delay execution for just a bit until db.QueryContext has begun.
+	defer time.AfterFunc(time.Millisecond*10, cancel).Stop()
+
+	// Not canceled until after the exec has started.
+	if _, err := db.QueryContext(ctx, "select pg_sleep(1)"); err == nil {
+		t.Fatal("expected error")
+	} else if err.Error() != "pq: canceling statement due to user request" {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	// Context is already canceled, so error should come before execution.
+	if _, err := db.QueryContext(ctx, "select pg_sleep(1)"); err == nil {
+		t.Fatal("expected error")
+	} else if err.Error() != "context canceled" {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	for i := 0; i < contextRaceIterations; i++ {
+		func() {
+			ctx, cancel := context.WithCancel(context.Background())
+			rows, err := db.QueryContext(ctx, "select 1")
+			cancel()
+			if err != nil {
+				t.Fatal(err)
+			} else if err := rows.Close(); err != nil {
+				t.Fatal(err)
+			}
+		}()
+
+		if rows, err := db.Query("select 1"); err != nil {
+			t.Fatal(err)
+		} else if err := rows.Close(); err != nil {
+			t.Fatal(err)
+		}
+	}
+}
+
+// TestIssue617 tests that a failed query in QueryContext doesn't lead to a
+// goroutine leak.
+func TestIssue617(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	const N = 10
+
+	numGoroutineStart := runtime.NumGoroutine()
+	for i := 0; i < N; i++ {
+		func() {
+			ctx, cancel := context.WithCancel(context.Background())
+			defer cancel()
+			_, err := db.QueryContext(ctx, `SELECT * FROM DOESNOTEXIST`)
+			pqErr, _ := err.(*Error)
+			// Expecting "pq: relation \"doesnotexist\" does not exist" error.
+			if err == nil || pqErr == nil || pqErr.Code != "42P01" {
+				t.Fatalf("expected undefined table error, got %v", err)
+			}
+		}()
+	}
+	numGoroutineFinish := runtime.NumGoroutine()
+
+	// We use N/2 and not N because the GC and other actors may increase or
+	// decrease the number of goroutines.
+	if numGoroutineFinish-numGoroutineStart >= N/2 {
+		t.Errorf("goroutine leak detected, was %d, now %d", numGoroutineStart, numGoroutineFinish)
+	}
+}
+
+func TestContextCancelBegin(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	ctx, cancel := context.WithCancel(context.Background())
+	tx, err := db.BeginTx(ctx, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	// Delay execution for just a bit until tx.Exec has begun.
+	defer time.AfterFunc(time.Millisecond*10, cancel).Stop()
+
+	// Not canceled until after the exec has started.
+	if _, err := tx.Exec("select pg_sleep(1)"); err == nil {
+		t.Fatal("expected error")
+	} else if err.Error() != "pq: canceling statement due to user request" {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	// Transaction is canceled, so expect an error.
+	if _, err := tx.Query("select pg_sleep(1)"); err == nil {
+		t.Fatal("expected error")
+	} else if err != sql.ErrTxDone {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	// Context is canceled, so cannot begin a transaction.
+	if _, err := db.BeginTx(ctx, nil); err == nil {
+		t.Fatal("expected error")
+	} else if err.Error() != "context canceled" {
+		t.Fatalf("unexpected error: %s", err)
+	}
+
+	for i := 0; i < contextRaceIterations; i++ {
+		func() {
+			ctx, cancel := context.WithCancel(context.Background())
+			tx, err := db.BeginTx(ctx, nil)
+			cancel()
+			if err != nil {
+				t.Fatal(err)
+			} else if err := tx.Rollback(); err != nil && err != sql.ErrTxDone {
+				t.Fatal(err)
+			}
+		}()
+
+		if tx, err := db.Begin(); err != nil {
+			t.Fatal(err)
+		} else if err := tx.Rollback(); err != nil {
+			t.Fatal(err)
+		}
+	}
+}
+
+func TestTxOptions(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+	ctx := context.Background()
+
+	tests := []struct {
+		level     sql.IsolationLevel
+		isolation string
+	}{
+		{
+			level:     sql.LevelDefault,
+			isolation: "",
+		},
+		{
+			level:     sql.LevelReadUncommitted,
+			isolation: "read uncommitted",
+		},
+		{
+			level:     sql.LevelReadCommitted,
+			isolation: "read committed",
+		},
+		{
+			level:     sql.LevelRepeatableRead,
+			isolation: "repeatable read",
+		},
+		{
+			level:     sql.LevelSerializable,
+			isolation: "serializable",
+		},
+	}
+
+	for _, test := range tests {
+		for _, ro := range []bool{true, false} {
+			tx, err := db.BeginTx(ctx, &sql.TxOptions{
+				Isolation: test.level,
+				ReadOnly:  ro,
+			})
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			var isolation string
+			err = tx.QueryRow("select current_setting('transaction_isolation')").Scan(&isolation)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			if test.isolation != "" && isolation != test.isolation {
+				t.Errorf("wrong isolation level: %s != %s", isolation, test.isolation)
+			}
+
+			var isRO string
+			err = tx.QueryRow("select current_setting('transaction_read_only')").Scan(&isRO)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			if ro != (isRO == "on") {
+				t.Errorf("read/[write,only] not set: %t != %s for level %s",
+					ro, isRO, test.isolation)
+			}
+
+			tx.Rollback()
+		}
+	}
+
+	_, err := db.BeginTx(ctx, &sql.TxOptions{
+		Isolation: sql.LevelLinearizable,
+	})
+	if err == nil {
+		t.Fatal("expected LevelLinearizable to fail")
+	}
+	if !strings.Contains(err.Error(), "isolation level not supported") {
+		t.Errorf("Expected error to mention isolation level, got %q", err)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore.go
new file mode 100644
index 0000000..72d5abf
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore.go
@@ -0,0 +1,118 @@
+package hstore
+
+import (
+	"database/sql"
+	"database/sql/driver"
+	"strings"
+)
+
+// A wrapper for transferring Hstore values back and forth easily.
+type Hstore struct {
+	Map map[string]sql.NullString
+}
+
+// escapes and quotes hstore keys/values
+// s should be a sql.NullString or string
+func hQuote(s interface{}) string {
+	var str string
+	switch v := s.(type) {
+	case sql.NullString:
+		if !v.Valid {
+			return "NULL"
+		}
+		str = v.String
+	case string:
+		str = v
+	default:
+		panic("not a string or sql.NullString")
+	}
+
+	str = strings.Replace(str, "\\", "\\\\", -1)
+	return `"` + strings.Replace(str, "\"", "\\\"", -1) + `"`
+}
+
+// Scan implements the Scanner interface.
+//
+// Note h.Map is reallocated before the scan to clear existing values. If the
+// hstore column's database value is NULL, then h.Map is set to nil instead.
+func (h *Hstore) Scan(value interface{}) error {
+	if value == nil {
+		h.Map = nil
+		return nil
+	}
+	h.Map = make(map[string]sql.NullString)
+	var b byte
+	pair := [][]byte{{}, {}}
+	pi := 0
+	inQuote := false
+	didQuote := false
+	sawSlash := false
+	bindex := 0
+	for bindex, b = range value.([]byte) {
+		if sawSlash {
+			pair[pi] = append(pair[pi], b)
+			sawSlash = false
+			continue
+		}
+
+		switch b {
+		case '\\':
+			sawSlash = true
+			continue
+		case '"':
+			inQuote = !inQuote
+			if !didQuote {
+				didQuote = true
+			}
+			continue
+		default:
+			if !inQuote {
+				switch b {
+				case ' ', '\t', '\n', '\r':
+					continue
+				case '=':
+					continue
+				case '>':
+					pi = 1
+					didQuote = false
+					continue
+				case ',':
+					s := string(pair[1])
+					if !didQuote && len(s) == 4 && strings.ToLower(s) == "null" {
+						h.Map[string(pair[0])] = sql.NullString{String: "", Valid: false}
+					} else {
+						h.Map[string(pair[0])] = sql.NullString{String: string(pair[1]), Valid: true}
+					}
+					pair[0] = []byte{}
+					pair[1] = []byte{}
+					pi = 0
+					continue
+				}
+			}
+		}
+		pair[pi] = append(pair[pi], b)
+	}
+	if bindex > 0 {
+		s := string(pair[1])
+		if !didQuote && len(s) == 4 && strings.ToLower(s) == "null" {
+			h.Map[string(pair[0])] = sql.NullString{String: "", Valid: false}
+		} else {
+			h.Map[string(pair[0])] = sql.NullString{String: string(pair[1]), Valid: true}
+		}
+	}
+	return nil
+}
+
+// Value implements the driver Valuer interface. Note if h.Map is nil, the
+// database column value will be set to NULL.
+func (h Hstore) Value() (driver.Value, error) {
+	if h.Map == nil {
+		return nil, nil
+	}
+	parts := []string{}
+	for key, val := range h.Map {
+		thispart := hQuote(key) + "=>" + hQuote(val)
+		parts = append(parts, thispart)
+	}
+	return []byte(strings.Join(parts, ",")), nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore_test.go
new file mode 100644
index 0000000..1c9f2bd
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/hstore/hstore_test.go
@@ -0,0 +1,148 @@
+package hstore
+
+import (
+	"database/sql"
+	"os"
+	"testing"
+
+	_ "github.com/lib/pq"
+)
+
+type Fatalistic interface {
+	Fatal(args ...interface{})
+}
+
+func openTestConn(t Fatalistic) *sql.DB {
+	datname := os.Getenv("PGDATABASE")
+	sslmode := os.Getenv("PGSSLMODE")
+
+	if datname == "" {
+		os.Setenv("PGDATABASE", "pqgotest")
+	}
+
+	if sslmode == "" {
+		os.Setenv("PGSSLMODE", "disable")
+	}
+
+	conn, err := sql.Open("postgres", "")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	return conn
+}
+
+func TestHstore(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	// quitely create hstore if it doesn't exist
+	_, err := db.Exec("CREATE EXTENSION IF NOT EXISTS hstore")
+	if err != nil {
+		t.Skipf("Skipping hstore tests - hstore extension create failed: %s", err.Error())
+	}
+
+	hs := Hstore{}
+
+	// test for null-valued hstores
+	err = db.QueryRow("SELECT NULL::hstore").Scan(&hs)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if hs.Map != nil {
+		t.Fatalf("expected null map")
+	}
+
+	err = db.QueryRow("SELECT $1::hstore", hs).Scan(&hs)
+	if err != nil {
+		t.Fatalf("re-query null map failed: %s", err.Error())
+	}
+	if hs.Map != nil {
+		t.Fatalf("expected null map")
+	}
+
+	// test for empty hstores
+	err = db.QueryRow("SELECT ''::hstore").Scan(&hs)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if hs.Map == nil {
+		t.Fatalf("expected empty map, got null map")
+	}
+	if len(hs.Map) != 0 {
+		t.Fatalf("expected empty map, got len(map)=%d", len(hs.Map))
+	}
+
+	err = db.QueryRow("SELECT $1::hstore", hs).Scan(&hs)
+	if err != nil {
+		t.Fatalf("re-query empty map failed: %s", err.Error())
+	}
+	if hs.Map == nil {
+		t.Fatalf("expected empty map, got null map")
+	}
+	if len(hs.Map) != 0 {
+		t.Fatalf("expected empty map, got len(map)=%d", len(hs.Map))
+	}
+
+	// a few example maps to test out
+	hsOnePair := Hstore{
+		Map: map[string]sql.NullString{
+			"key1": {String: "value1", Valid: true},
+		},
+	}
+
+	hsThreePairs := Hstore{
+		Map: map[string]sql.NullString{
+			"key1": {String: "value1", Valid: true},
+			"key2": {String: "value2", Valid: true},
+			"key3": {String: "value3", Valid: true},
+		},
+	}
+
+	hsSmorgasbord := Hstore{
+		Map: map[string]sql.NullString{
+			"nullstring":             {String: "NULL", Valid: true},
+			"actuallynull":           {String: "", Valid: false},
+			"NULL":                   {String: "NULL string key", Valid: true},
+			"withbracket":            {String: "value>42", Valid: true},
+			"withequal":              {String: "value=42", Valid: true},
+			`"withquotes1"`:          {String: `this "should" be fine`, Valid: true},
+			`"withquotes"2"`:         {String: `this "should\" also be fine`, Valid: true},
+			"embedded1":              {String: "value1=>x1", Valid: true},
+			"embedded2":              {String: `"value2"=>x2`, Valid: true},
+			"withnewlines":           {String: "\n\nvalue\t=>2", Valid: true},
+			"<<all sorts of crazy>>": {String: `this, "should,\" also, => be fine`, Valid: true},
+		},
+	}
+
+	// test encoding in query params, then decoding during Scan
+	testBidirectional := func(h Hstore) {
+		err = db.QueryRow("SELECT $1::hstore", h).Scan(&hs)
+		if err != nil {
+			t.Fatalf("re-query %d-pair map failed: %s", len(h.Map), err.Error())
+		}
+		if hs.Map == nil {
+			t.Fatalf("expected %d-pair map, got null map", len(h.Map))
+		}
+		if len(hs.Map) != len(h.Map) {
+			t.Fatalf("expected %d-pair map, got len(map)=%d", len(h.Map), len(hs.Map))
+		}
+
+		for key, val := range hs.Map {
+			otherval, found := h.Map[key]
+			if !found {
+				t.Fatalf("  key '%v' not found in %d-pair map", key, len(h.Map))
+			}
+			if otherval.Valid != val.Valid {
+				t.Fatalf("  value %v <> %v in %d-pair map", otherval, val, len(h.Map))
+			}
+			if otherval.String != val.String {
+				t.Fatalf("  value '%v' <> '%v' in %d-pair map", otherval.String, val.String, len(h.Map))
+			}
+		}
+	}
+
+	testBidirectional(hsOnePair)
+	testBidirectional(hsThreePairs)
+	testBidirectional(hsSmorgasbord)
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/issues_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/issues_test.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/issues_test.go
new file mode 100644
index 0000000..3a330a0
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/issues_test.go
@@ -0,0 +1,26 @@
+package pq
+
+import "testing"
+
+func TestIssue494(t *testing.T) {
+	db := openTestConn(t)
+	defer db.Close()
+
+	query := `CREATE TEMP TABLE t (i INT PRIMARY KEY)`
+	if _, err := db.Exec(query); err != nil {
+		t.Fatal(err)
+	}
+
+	txn, err := db.Begin()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if _, err := txn.Prepare(CopyIn("t", "i")); err != nil {
+		t.Fatal(err)
+	}
+
+	if _, err := txn.Query("SELECT 1"); err == nil {
+		t.Fatal("expected error")
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/listen_example/doc.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/listen_example/doc.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/listen_example/doc.go
new file mode 100644
index 0000000..80f0a9b
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/listen_example/doc.go
@@ -0,0 +1,96 @@
+/*
+
+Below you will find a self-contained Go program which uses the LISTEN / NOTIFY
+mechanism to avoid polling the database while waiting for more work to arrive.
+
+    //
+    // You can see the program in action by defining a function similar to
+    // the following:
+    //
+    // CREATE OR REPLACE FUNCTION public.get_work()
+    //   RETURNS bigint
+    //   LANGUAGE sql
+    //   AS $$
+    //     SELECT CASE WHEN random() >= 0.2 THEN int8 '1' END
+    //   $$
+    // ;
+
+    package main
+
+    import (
+        "database/sql"
+        "fmt"
+        "time"
+
+        "github.com/lib/pq"
+    )
+
+    func doWork(db *sql.DB, work int64) {
+        // work here
+    }
+
+    func getWork(db *sql.DB) {
+        for {
+            // get work from the database here
+            var work sql.NullInt64
+            err := db.QueryRow("SELECT get_work()").Scan(&work)
+            if err != nil {
+                fmt.Println("call to get_work() failed: ", err)
+                time.Sleep(10 * time.Second)
+                continue
+            }
+            if !work.Valid {
+                // no more work to do
+                fmt.Println("ran out of work")
+                return
+            }
+
+            fmt.Println("starting work on ", work.Int64)
+            go doWork(db, work.Int64)
+        }
+    }
+
+    func waitForNotification(l *pq.Listener) {
+        select {
+            case <-l.Notify:
+                fmt.Println("received notification, new work available")
+            case <-time.After(90 * time.Second):
+                go l.Ping()
+                // Check if there's more work available, just in case it takes
+                // a while for the Listener to notice connection loss and
+                // reconnect.
+                fmt.Println("received no work for 90 seconds, checking for new work")
+        }
+    }
+
+    func main() {
+        var conninfo string = ""
+
+        db, err := sql.Open("postgres", conninfo)
+        if err != nil {
+            panic(err)
+        }
+
+        reportProblem := func(ev pq.ListenerEventType, err error) {
+            if err != nil {
+                fmt.Println(err.Error())
+            }
+        }
+
+        listener := pq.NewListener(conninfo, 10 * time.Second, time.Minute, reportProblem)
+        err = listener.Listen("getwork")
+        if err != nil {
+            panic(err)
+        }
+
+        fmt.Println("entering main loop")
+        for {
+            // process all available work before waiting for notifications
+            getWork(db)
+            waitForNotification(listener)
+        }
+    }
+
+
+*/
+package listen_example

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify.go
new file mode 100644
index 0000000..09f9424
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/notify.go
@@ -0,0 +1,782 @@
+package pq
+
+// Package pq is a pure Go Postgres driver for the database/sql package.
+// This module contains support for Postgres LISTEN/NOTIFY.
+
+import (
+	"errors"
+	"fmt"
+	"sync"
+	"sync/atomic"
+	"time"
+)
+
+// Notification represents a single notification from the database.
+type Notification struct {
+	// Process ID (PID) of the notifying postgres backend.
+	BePid int
+	// Name of the channel the notification was sent on.
+	Channel string
+	// Payload, or the empty string if unspecified.
+	Extra string
+}
+
+func recvNotification(r *readBuf) *Notification {
+	bePid := r.int32()
+	channel := r.string()
+	extra := r.string()
+
+	return &Notification{bePid, channel, extra}
+}
+
+const (
+	connStateIdle int32 = iota
+	connStateExpectResponse
+	connStateExpectReadyForQuery
+)
+
+type message struct {
+	typ byte
+	err error
+}
+
+var errListenerConnClosed = errors.New("pq: ListenerConn has been closed")
+
+// ListenerConn is a low-level interface for waiting for notifications.  You
+// should use Listener instead.
+type ListenerConn struct {
+	// guards cn and err
+	connectionLock sync.Mutex
+	cn             *conn
+	err            error
+
+	connState int32
+
+	// the sending goroutine will be holding this lock
+	senderLock sync.Mutex
+
+	notificationChan chan<- *Notification
+
+	replyChan chan message
+}
+
+// Creates a new ListenerConn.  Use NewListener instead.
+func NewListenerConn(name string, notificationChan chan<- *Notification) (*ListenerConn, error) {
+	return newDialListenerConn(defaultDialer{}, name, notificationChan)
+}
+
+func newDialListenerConn(d Dialer, name string, c chan<- *Notification) (*ListenerConn, error) {
+	cn, err := DialOpen(d, name)
+	if err != nil {
+		return nil, err
+	}
+
+	l := &ListenerConn{
+		cn:               cn.(*conn),
+		notificationChan: c,
+		connState:        connStateIdle,
+		replyChan:        make(chan message, 2),
+	}
+
+	go l.listenerConnMain()
+
+	return l, nil
+}
+
+// We can only allow one goroutine at a time to be running a query on the
+// connection for various reasons, so the goroutine sending on the connection
+// must be holding senderLock.
+//
+// Returns an error if an unrecoverable error has occurred and the ListenerConn
+// should be abandoned.
+func (l *ListenerConn) acquireSenderLock() error {
+	// we must acquire senderLock first to avoid deadlocks; see ExecSimpleQuery
+	l.senderLock.Lock()
+
+	l.connectionLock.Lock()
+	err := l.err
+	l.connectionLock.Unlock()
+	if err != nil {
+		l.senderLock.Unlock()
+		return err
+	}
+	return nil
+}
+
+func (l *ListenerConn) releaseSenderLock() {
+	l.senderLock.Unlock()
+}
+
+// setState advances the protocol state to newState.  Returns false if moving
+// to that state from the current state is not allowed.
+func (l *ListenerConn) setState(newState int32) bool {
+	var expectedState int32
+
+	switch newState {
+	case connStateIdle:
+		expectedState = connStateExpectReadyForQuery
+	case connStateExpectResponse:
+		expectedState = connStateIdle
+	case connStateExpectReadyForQuery:
+		expectedState = connStateExpectResponse
+	default:
+		panic(fmt.Sprintf("unexpected listenerConnState %d", newState))
+	}
+
+	return atomic.CompareAndSwapInt32(&l.connState, expectedState, newState)
+}
+
+// Main logic is here: receive messages from the postgres backend, forward
+// notifications and query replies and keep the internal state in sync with the
+// protocol state.  Returns when the connection has been lost, is about to go
+// away or should be discarded because we couldn't agree on the state with the
+// server backend.
+func (l *ListenerConn) listenerConnLoop() (err error) {
+	defer errRecoverNoErrBadConn(&err)
+
+	r := &readBuf{}
+	for {
+		t, err := l.cn.recvMessage(r)
+		if err != nil {
+			return err
+		}
+
+		switch t {
+		case 'A':
+			// recvNotification copies all the data so we don't need to worry
+			// about the scratch buffer being overwritten.
+			l.notificationChan <- recvNotification(r)
+
+		case 'T', 'D':
+			// only used by tests; ignore
+
+		case 'E':
+			// We might receive an ErrorResponse even when not in a query; it
+			// is expected that the server will close the connection after
+			// that, but we should make sure that the error we display is the
+			// one from the stray ErrorResponse, not io.ErrUnexpectedEOF.
+			if !l.setState(connStateExpectReadyForQuery) {
+				return parseError(r)
+			}
+			l.replyChan <- message{t, parseError(r)}
+
+		case 'C', 'I':
+			if !l.setState(connStateExpectReadyForQuery) {
+				// protocol out of sync
+				return fmt.Errorf("unexpected CommandComplete")
+			}
+			// ExecSimpleQuery doesn't need to know about this message
+
+		case 'Z':
+			if !l.setState(connStateIdle) {
+				// protocol out of sync
+				return fmt.Errorf("unexpected ReadyForQuery")
+			}
+			l.replyChan <- message{t, nil}
+
+		case 'N', 'S':
+			// ignore
+		default:
+			return fmt.Errorf("unexpected message %q from server in listenerConnLoop", t)
+		}
+	}
+}
+
+// This is the main routine for the goroutine receiving on the database
+// connection.  Most of the main logic is in listenerConnLoop.
+func (l *ListenerConn) listenerConnMain() {
+	err := l.listenerConnLoop()
+
+	// listenerConnLoop terminated; we're done, but we still have to clean up.
+	// Make sure nobody tries to start any new queries by making sure the err
+	// pointer is set.  It is important that we do not overwrite its value; a
+	// connection could be closed by either this goroutine or one sending on
+	// the connection -- whoever closes the connection is assumed to have the
+	// more meaningful error message (as the other one will probably get
+	// net.errClosed), so that goroutine sets the error we expose while the
+	// other error is discarded.  If the connection is lost while two
+	// goroutines are operating on the socket, it probably doesn't matter which
+	// error we expose so we don't try to do anything more complex.
+	l.connectionLock.Lock()
+	if l.err == nil {
+		l.err = err
+	}
+	l.cn.Close()
+	l.connectionLock.Unlock()
+
+	// There might be a query in-flight; make sure nobody's waiting for a
+	// response to it, since there's not going to be one.
+	close(l.replyChan)
+
+	// let the listener know we're done
+	close(l.notificationChan)
+
+	// this ListenerConn is done
+}
+
+// Send a LISTEN query to the server.  See ExecSimpleQuery.
+func (l *ListenerConn) Listen(channel string) (bool, error) {
+	return l.ExecSimpleQuery("LISTEN " + QuoteIdentifier(channel))
+}
+
+// Send an UNLISTEN query to the server.  See ExecSimpleQuery.
+func (l *ListenerConn) Unlisten(channel string) (bool, error) {
+	return l.ExecSimpleQuery("UNLISTEN " + QuoteIdentifier(channel))
+}
+
+// Send `UNLISTEN *` to the server.  See ExecSimpleQuery.
+func (l *ListenerConn) UnlistenAll() (bool, error) {
+	return l.ExecSimpleQuery("UNLISTEN *")
+}
+
+// Ping the remote server to make sure it's alive.  Non-nil error means the
+// connection has failed and should be abandoned.
+func (l *ListenerConn) Ping() error {
+	sent, err := l.ExecSimpleQuery("")
+	if !sent {
+		return err
+	}
+	if err != nil {
+		// shouldn't happen
+		panic(err)
+	}
+	return nil
+}
+
+// Attempt to send a query on the connection.  Returns an error if sending the
+// query failed, and the caller should initiate closure of this connection.
+// The caller must be holding senderLock (see acquireSenderLock and
+// releaseSenderLock).
+func (l *ListenerConn) sendSimpleQuery(q string) (err error) {
+	defer errRecoverNoErrBadConn(&err)
+
+	// must set connection state before sending the query
+	if !l.setState(connStateExpectResponse) {
+		panic("two queries running at the same time")
+	}
+
+	// Can't use l.cn.writeBuf here because it uses the scratch buffer which
+	// might get overwritten by listenerConnLoop.
+	b := &writeBuf{
+		buf: []byte("Q\x00\x00\x00\x00"),
+		pos: 1,
+	}
+	b.string(q)
+	l.cn.send(b)
+
+	return nil
+}
+
+// Execute a "simple query" (i.e. one with no bindable parameters) on the
+// connection.  The possible return values are:
+//   1) "executed" is true; the query was executed to completion on the
+//      database server.  If the query failed, err will be set to the error
+//      returned by the database, otherwise err will be nil.
+//   2) If "executed" is false, the query could not be executed on the remote
+//      server.  err will be non-nil.
+//
+// After a call to ExecSimpleQuery has returned an executed=false value, the
+// connection has either been closed or will be closed shortly thereafter, and
+// all subsequently executed queries will return an error.
+func (l *ListenerConn) ExecSimpleQuery(q string) (executed bool, err error) {
+	if err = l.acquireSenderLock(); err != nil {
+		return false, err
+	}
+	defer l.releaseSenderLock()
+
+	err = l.sendSimpleQuery(q)
+	if err != nil {
+		// We can't know what state the protocol is in, so we need to abandon
+		// this connection.
+		l.connectionLock.Lock()
+		// Set the error pointer if it hasn't been set already; see
+		// listenerConnMain.
+		if l.err == nil {
+			l.err = err
+		}
+		l.connectionLock.Unlock()
+		l.cn.c.Close()
+		return false, err
+	}
+
+	// now we just wait for a reply..
+	for {
+		m, ok := <-l.replyChan
+		if !ok {
+			// We lost the connection to server, don't bother waiting for a
+			// a response.  err should have been set already.
+			l.connectionLock.Lock()
+			err := l.err
+			l.connectionLock.Unlock()
+			return false, err
+		}
+		switch m.typ {
+		case 'Z':
+			// sanity check
+			if m.err != nil {
+				panic("m.err != nil")
+			}
+			// done; err might or might not be set
+			return true, err
+
+		case 'E':
+			// sanity check
+			if m.err == nil {
+				panic("m.err == nil")
+			}
+			// server responded with an error; ReadyForQuery to follow
+			err = m.err
+
+		default:
+			return false, fmt.Errorf("unknown response for simple query: %q", m.typ)
+		}
+	}
+}
+
+func (l *ListenerConn) Close() error {
+	l.connectionLock.Lock()
+	if l.err != nil {
+		l.connectionLock.Unlock()
+		return errListenerConnClosed
+	}
+	l.err = errListenerConnClosed
+	l.connectionLock.Unlock()
+	// We can't send anything on the connection without holding senderLock.
+	// Simply close the net.Conn to wake up everyone operating on it.
+	return l.cn.c.Close()
+}
+
+// Err() returns the reason the connection was closed.  It is not safe to call
+// this function until l.Notify has been closed.
+func (l *ListenerConn) Err() error {
+	return l.err
+}
+
+var errListenerClosed = errors.New("pq: Listener has been closed")
+
+var ErrChannelAlreadyOpen = errors.New("pq: channel is already open")
+var ErrChannelNotOpen = errors.New("pq: channel is not open")
+
+type ListenerEventType int
+
+const (
+	// Emitted only when the database connection has been initially
+	// initialized.  err will always be nil.
+	ListenerEventConnected ListenerEventType = iota
+
+	// Emitted after a database connection has been lost, either because of an
+	// error or because Close has been called.  err will be set to the reason
+	// the database connection was lost.
+	ListenerEventDisconnected
+
+	// Emitted after a database connection has been re-established after
+	// connection loss.  err will always be nil.  After this event has been
+	// emitted, a nil pq.Notification is sent on the Listener.Notify channel.
+	ListenerEventReconnected
+
+	// Emitted after a connection to the database was attempted, but failed.
+	// err will be set to an error describing why the connection attempt did
+	// not succeed.
+	ListenerEventConnectionAttemptFailed
+)
+
+type EventCallbackType func(event ListenerEventType, err error)
+
+// Listener provides an interface for listening to notifications from a
+// PostgreSQL database.  For general usage information, see section
+// "Notifications".
+//
+// Listener can safely be used from concurrently running goroutines.
+type Listener struct {
+	// Channel for receiving notifications from the database.  In some cases a
+	// nil value will be sent.  See section "Notifications" above.
+	Notify chan *Notification
+
+	name                 string
+	minReconnectInterval time.Duration
+	maxReconnectInterval time.Duration
+	dialer               Dialer
+	eventCallback        EventCallbackType
+
+	lock                 sync.Mutex
+	isClosed             bool
+	reconnectCond        *sync.Cond
+	cn                   *ListenerConn
+	connNotificationChan <-chan *Notification
+	channels             map[string]struct{}
+}
+
+// NewListener creates a new database connection dedicated to LISTEN / NOTIFY.
+//
+// name should be set to a connection string to be used to establish the
+// database connection (see section "Connection String Parameters" above).
+//
+// minReconnectInterval controls the duration to wait before trying to
+// re-establish the database connection after connection loss.  After each
+// consecutive failure this interval is doubled, until maxReconnectInterval is
+// reached.  Successfully completing the connection establishment procedure
+// resets the interval back to minReconnectInterval.
+//
+// The last parameter eventCallback can be set to a function which will be
+// called by the Listener when the state of the underlying database connection
+// changes.  This callback will be called by the goroutine which dispatches the
+// notifications over the Notify channel, so you should try to avoid doing
+// potentially time-consuming operations from the callback.
+func NewListener(name string,
+	minReconnectInterval time.Duration,
+	maxReconnectInterval time.Duration,
+	eventCallback EventCallbackType) *Listener {
+	return NewDialListener(defaultDialer{}, name, minReconnectInterval, maxReconnectInterval, eventCallback)
+}
+
+// NewDialListener is like NewListener but it takes a Dialer.
+func NewDialListener(d Dialer,
+	name string,
+	minReconnectInterval time.Duration,
+	maxReconnectInterval time.Duration,
+	eventCallback EventCallbackType) *Listener {
+
+	l := &Listener{
+		name:                 name,
+		minReconnectInterval: minReconnectInterval,
+		maxReconnectInterval: maxReconnectInterval,
+		dialer:               d,
+		eventCallback:        eventCallback,
+
+		channels: make(map[string]struct{}),
+
+		Notify: make(chan *Notification, 32),
+	}
+	l.reconnectCond = sync.NewCond(&l.lock)
+
+	go l.listenerMain()
+
+	return l
+}
+
+// Returns the notification channel for this listener.  This is the same
+// channel as Notify, and will not be recreated during the life time of the
+// Listener.
+func (l *Listener) NotificationChannel() <-chan *Notification {
+	return l.Notify
+}
+
+// Listen starts listening for notifications on a channel.  Calls to this
+// function will block until an acknowledgement has been received from the
+// server.  Note that Listener automatically re-establishes the connection
+// after connection loss, so this function may block indefinitely if the
+// connection can not be re-established.
+//
+// Listen will only fail in three conditions:
+//   1) The channel is already open.  The returned error will be
+//      ErrChannelAlreadyOpen.
+//   2) The query was executed on the remote server, but PostgreSQL returned an
+//      error message in response to the query.  The returned error will be a
+//      pq.Error containing the information the server supplied.
+//   3) Close is called on the Listener before the request could be completed.
+//
+// The channel name is case-sensitive.
+func (l *Listener) Listen(channel string) error {
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	if l.isClosed {
+		return errListenerClosed
+	}
+
+	// The server allows you to issue a LISTEN on a channel which is already
+	// open, but it seems useful to be able to detect this case to spot for
+	// mistakes in application logic.  If the application genuinely does't
+	// care, it can check the exported error and ignore it.
+	_, exists := l.channels[channel]
+	if exists {
+		return ErrChannelAlreadyOpen
+	}
+
+	if l.cn != nil {
+		// If gotResponse is true but error is set, the query was executed on
+		// the remote server, but resulted in an error.  This should be
+		// relatively rare, so it's fine if we just pass the error to our
+		// caller.  However, if gotResponse is false, we could not complete the
+		// query on the remote server and our underlying connection is about
+		// to go away, so we only add relname to l.channels, and wait for
+		// resync() to take care of the rest.
+		gotResponse, err := l.cn.Listen(channel)
+		if gotResponse && err != nil {
+			return err
+		}
+	}
+
+	l.channels[channel] = struct{}{}
+	for l.cn == nil {
+		l.reconnectCond.Wait()
+		// we let go of the mutex for a while
+		if l.isClosed {
+			return errListenerClosed
+		}
+	}
+
+	return nil
+}
+
+// Unlisten removes a channel from the Listener's channel list.  Returns
+// ErrChannelNotOpen if the Listener is not listening on the specified channel.
+// Returns immediately with no error if there is no connection.  Note that you
+// might still get notifications for this channel even after Unlisten has
+// returned.
+//
+// The channel name is case-sensitive.
+func (l *Listener) Unlisten(channel string) error {
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	if l.isClosed {
+		return errListenerClosed
+	}
+
+	// Similarly to LISTEN, this is not an error in Postgres, but it seems
+	// useful to distinguish from the normal conditions.
+	_, exists := l.channels[channel]
+	if !exists {
+		return ErrChannelNotOpen
+	}
+
+	if l.cn != nil {
+		// Similarly to Listen (see comment in that function), the caller
+		// should only be bothered with an error if it came from the backend as
+		// a response to our query.
+		gotResponse, err := l.cn.Unlisten(channel)
+		if gotResponse && err != nil {
+			return err
+		}
+	}
+
+	// Don't bother waiting for resync if there's no connection.
+	delete(l.channels, channel)
+	return nil
+}
+
+// UnlistenAll removes all channels from the Listener's channel list.  Returns
+// immediately with no error if there is no connection.  Note that you might
+// still get notifications for any of the deleted channels even after
+// UnlistenAll has returned.
+func (l *Listener) UnlistenAll() error {
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	if l.isClosed {
+		return errListenerClosed
+	}
+
+	if l.cn != nil {
+		// Similarly to Listen (see comment in that function), the caller
+		// should only be bothered with an error if it came from the backend as
+		// a response to our query.
+		gotResponse, err := l.cn.UnlistenAll()
+		if gotResponse && err != nil {
+			return err
+		}
+	}
+
+	// Don't bother waiting for resync if there's no connection.
+	l.channels = make(map[string]struct{})
+	return nil
+}
+
+// Ping the remote server to make sure it's alive.  Non-nil return value means
+// that there is no active connection.
+func (l *Listener) Ping() error {
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	if l.isClosed {
+		return errListenerClosed
+	}
+	if l.cn == nil {
+		return errors.New("no connection")
+	}
+
+	return l.cn.Ping()
+}
+
+// Clean up after losing the server connection.  Returns l.cn.Err(), which
+// should have the reason the connection was lost.
+func (l *Listener) disconnectCleanup() error {
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	// sanity check; can't look at Err() until the channel has been closed
+	select {
+	case _, ok := <-l.connNotificationChan:
+		if ok {
+			panic("connNotificationChan not closed")
+		}
+	default:
+		panic("connNotificationChan not closed")
+	}
+
+	err := l.cn.Err()
+	l.cn.Close()
+	l.cn = nil
+	return err
+}
+
+// Synchronize the list of channels we want to be listening on with the server
+// after the connection has been established.
+func (l *Listener) resync(cn *ListenerConn, notificationChan <-chan *Notification) error {
+	doneChan := make(chan error)
+	go func() {
+		for channel := range l.channels {
+			// If we got a response, return that error to our caller as it's
+			// going to be more descriptive than cn.Err().
+			gotResponse, err := cn.Listen(channel)
+			if gotResponse && err != nil {
+				doneChan <- err
+				return
+			}
+
+			// If we couldn't reach the server, wait for notificationChan to
+			// close and then return the error message from the connection, as
+			// per ListenerConn's interface.
+			if err != nil {
+				for _ = range notificationChan {
+				}
+				doneChan <- cn.Err()
+				return
+			}
+		}
+		doneChan <- nil
+	}()
+
+	// Ignore notifications while synchronization is going on to avoid
+	// deadlocks.  We have to send a nil notification over Notify anyway as
+	// we can't possibly know which notifications (if any) were lost while
+	// the connection was down, so there's no reason to try and process
+	// these messages at all.
+	for {
+		select {
+		case _, ok := <-notificationChan:
+			if !ok {
+				notificationChan = nil
+			}
+
+		case err := <-doneChan:
+			return err
+		}
+	}
+}
+
+// caller should NOT be holding l.lock
+func (l *Listener) closed() bool {
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	return l.isClosed
+}
+
+func (l *Listener) connect() error {
+	notificationChan := make(chan *Notification, 32)
+	cn, err := newDialListenerConn(l.dialer, l.name, notificationChan)
+	if err != nil {
+		return err
+	}
+
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	err = l.resync(cn, notificationChan)
+	if err != nil {
+		cn.Close()
+		return err
+	}
+
+	l.cn = cn
+	l.connNotificationChan = notificationChan
+	l.reconnectCond.Broadcast()
+
+	return nil
+}
+
+// Close disconnects the Listener from the database and shuts it down.
+// Subsequent calls to its methods will return an error.  Close returns an
+// error if the connection has already been closed.
+func (l *Listener) Close() error {
+	l.lock.Lock()
+	defer l.lock.Unlock()
+
+	if l.isClosed {
+		return errListenerClosed
+	}
+
+	if l.cn != nil {
+		l.cn.Close()
+	}
+	l.isClosed = true
+
+	return nil
+}
+
+func (l *Listener) emitEvent(event ListenerEventType, err error) {
+	if l.eventCallback != nil {
+		l.eventCallback(event, err)
+	}
+}
+
+// Main logic here: maintain a connection to the server when possible, wait
+// for notifications and emit events.
+func (l *Listener) listenerConnLoop() {
+	var nextReconnect time.Time
+
+	reconnectInterval := l.minReconnectInterval
+	for {
+		for {
+			err := l.connect()
+			if err == nil {
+				break
+			}
+
+			if l.closed() {
+				return
+			}
+			l.emitEvent(ListenerEventConnectionAttemptFailed, err)
+
+			time.Sleep(reconnectInterval)
+			reconnectInterval *= 2
+			if reconnectInterval > l.maxReconnectInterval {
+				reconnectInterval = l.maxReconnectInterval
+			}
+		}
+
+		if nextReconnect.IsZero() {
+			l.emitEvent(ListenerEventConnected, nil)
+		} else {
+			l.emitEvent(ListenerEventReconnected, nil)
+			l.Notify <- nil
+		}
+
+		reconnectInterval = l.minReconnectInterval
+		nextReconnect = time.Now().Add(reconnectInterval)
+
+		for {
+			notification, ok := <-l.connNotificationChan
+			if !ok {
+				// lost connection, loop again
+				break
+			}
+			l.Notify <- notification
+		}
+
+		err := l.disconnectCleanup()
+		if l.closed() {
+			return
+		}
+		l.emitEvent(ListenerEventDisconnected, err)
+
+		time.Sleep(nextReconnect.Sub(time.Now()))
+	}
+}
+
+func (l *Listener) listenerMain() {
+	l.listenerConnLoop()
+	close(l.Notify)
+}


[7/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.crt
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.crt b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.crt
new file mode 100644
index 0000000..6e6b428
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.crt
@@ -0,0 +1,69 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number: 2 (0x2)
+        Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=Nevada, L=Las Vegas, O=github.com/lib/pq, CN=pq CA
+        Validity
+            Not Before: Oct 11 15:10:11 2014 GMT
+            Not After : Oct  8 15:10:11 2024 GMT
+        Subject: C=US, ST=Nevada, L=Las Vegas, O=github.com/lib/pq, CN=pqgosslcert
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+            RSA Public Key: (1024 bit)
+                Modulus (1024 bit):
+                    00:e3:8c:06:9a:70:54:51:d1:34:34:83:39:cd:a2:
+                    59:0f:05:ed:8d:d8:0e:34:d0:92:f4:09:4d:ee:8c:
+                    78:55:49:24:f8:3c:e0:34:58:02:b2:e7:94:58:c1:
+                    e8:e5:bb:d1:af:f6:54:c1:40:b1:90:70:79:0d:35:
+                    54:9c:8f:16:e9:c2:f0:92:e6:64:49:38:c1:76:f8:
+                    47:66:c4:5b:4a:b6:a9:43:ce:c8:be:6c:4d:2b:94:
+                    97:3c:55:bc:d1:d0:6e:b7:53:ae:89:5c:4b:6b:86:
+                    40:be:c1:ae:1e:64:ce:9c:ae:87:0a:69:e5:c8:21:
+                    12:be:ae:1d:f6:45:df:16:a7
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Subject Key Identifier: 
+                9B:25:31:63:A2:D8:06:FF:CB:E3:E9:96:FF:0D:BA:DC:12:7D:04:CF
+            X509v3 Authority Key Identifier: 
+                keyid:52:93:ED:1E:76:0A:9F:65:4F:DE:19:66:C1:D5:22:40:35:CB:A0:72
+
+            X509v3 Basic Constraints: 
+                CA:FALSE
+            X509v3 Key Usage: 
+                Digital Signature, Non Repudiation, Key Encipherment
+    Signature Algorithm: sha256WithRSAEncryption
+        3e:f5:f8:0b:4e:11:bd:00:86:1f:ce:dc:97:02:98:91:11:f5:
+        65:f6:f2:8a:b2:3e:47:92:05:69:28:c9:e9:b4:f7:cf:93:d1:
+        2d:81:5d:00:3c:23:be:da:70:ea:59:e1:2c:d3:25:49:ae:a6:
+        95:54:c1:10:df:23:e3:fe:d6:e4:76:c7:6b:73:ad:1b:34:7c:
+        e2:56:cc:c0:37:ae:c5:7a:11:20:6c:3d:05:0e:99:cd:22:6c:
+        cf:59:a1:da:28:d4:65:ba:7d:2f:2b:3d:69:6d:a6:c1:ae:57:
+        bf:56:64:13:79:f8:48:46:65:eb:81:67:28:0b:7b:de:47:10:
+        b3:80:3c:31:d1:58:94:01:51:4a:c7:c8:1a:01:a8:af:c4:cd:
+        bb:84:a5:d9:8b:b4:b9:a1:64:3e:95:d9:90:1d:d5:3f:67:cc:
+        3b:ba:f5:b4:d1:33:77:ee:c2:d2:3e:7e:c5:66:6e:b7:35:4c:
+        60:57:b0:b8:be:36:c8:f3:d3:95:8c:28:4a:c9:f7:27:a4:0d:
+        e5:96:99:eb:f5:c8:bd:f3:84:6d:ef:02:f9:8a:36:7d:6b:5f:
+        36:68:37:41:d9:74:ae:c6:78:2e:44:86:a1:ad:43:ca:fb:b5:
+        3e:ba:10:23:09:02:ac:62:d1:d0:83:c8:95:b9:e3:5e:30:ff:
+        5b:2b:38:fa
+-----BEGIN CERTIFICATE-----
+MIIDEzCCAfugAwIBAgIBAjANBgkqhkiG9w0BAQsFADBeMQswCQYDVQQGEwJVUzEP
+MA0GA1UECBMGTmV2YWRhMRIwEAYDVQQHEwlMYXMgVmVnYXMxGjAYBgNVBAoTEWdp
+dGh1Yi5jb20vbGliL3BxMQ4wDAYDVQQDEwVwcSBDQTAeFw0xNDEwMTExNTEwMTFa
+Fw0yNDEwMDgxNTEwMTFaMGQxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZOZXZhZGEx
+EjAQBgNVBAcTCUxhcyBWZWdhczEaMBgGA1UEChMRZ2l0aHViLmNvbS9saWIvcHEx
+FDASBgNVBAMTC3BxZ29zc2xjZXJ0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
+gQDjjAaacFRR0TQ0gznNolkPBe2N2A400JL0CU3ujHhVSST4POA0WAKy55RYwejl
+u9Gv9lTBQLGQcHkNNVScjxbpwvCS5mRJOMF2+EdmxFtKtqlDzsi+bE0rlJc8VbzR
+0G63U66JXEtrhkC+wa4eZM6crocKaeXIIRK+rh32Rd8WpwIDAQABo1owWDAdBgNV
+HQ4EFgQUmyUxY6LYBv/L4+mW/w263BJ9BM8wHwYDVR0jBBgwFoAUUpPtHnYKn2VP
+3hlmwdUiQDXLoHIwCQYDVR0TBAIwADALBgNVHQ8EBAMCBeAwDQYJKoZIhvcNAQEL
+BQADggEBAD71+AtOEb0Ahh/O3JcCmJER9WX28oqyPkeSBWkoyem098+T0S2BXQA8
+I77acOpZ4SzTJUmuppVUwRDfI+P+1uR2x2tzrRs0fOJWzMA3rsV6ESBsPQUOmc0i
+bM9Zodoo1GW6fS8rPWltpsGuV79WZBN5+EhGZeuBZygLe95HELOAPDHRWJQBUUrH
+yBoBqK/EzbuEpdmLtLmhZD6V2ZAd1T9nzDu69bTRM3fuwtI+fsVmbrc1TGBXsLi+
+Nsjz05WMKErJ9yekDeWWmev1yL3zhG3vAvmKNn1rXzZoN0HZdK7GeC5EhqGtQ8r7
+tT66ECMJAqxi0dCDyJW5414w/1srOPo=
+-----END CERTIFICATE-----

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.key
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.key b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.key
new file mode 100644
index 0000000..eb8b20b
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/postgresql.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQDjjAaacFRR0TQ0gznNolkPBe2N2A400JL0CU3ujHhVSST4POA0
+WAKy55RYwejlu9Gv9lTBQLGQcHkNNVScjxbpwvCS5mRJOMF2+EdmxFtKtqlDzsi+
+bE0rlJc8VbzR0G63U66JXEtrhkC+wa4eZM6crocKaeXIIRK+rh32Rd8WpwIDAQAB
+AoGAM5dM6/kp9P700i8qjOgRPym96Zoh5nGfz/rIE5z/r36NBkdvIg8OVZfR96nH
+b0b9TOMR5lsPp0sI9yivTWvX6qyvLJRWy2vvx17hXK9NxXUNTAm0PYZUTvCtcPeX
+RnJpzQKNZQPkFzF0uXBc4CtPK2Vz0+FGvAelrhYAxnw1dIkCQQD+9qaW5QhXjsjb
+Nl85CmXgxPmGROcgLQCO+omfrjf9UXrituU9Dz6auym5lDGEdMFnkzfr+wpasEy9
+mf5ZZOhDAkEA5HjXfVGaCtpydOt6hDon/uZsyssCK2lQ7NSuE3vP+sUsYMzIpEoy
+t3VWXqKbo+g9KNDTP4WEliqp1aiSIylzzQJANPeqzihQnlgEdD4MdD4rwhFJwVIp
+Le8Lcais1KaN7StzOwxB/XhgSibd2TbnPpw+3bSg5n5lvUdo+e62/31OHwJAU1jS
+I+F09KikQIr28u3UUWT2IzTT4cpVv1AHAQyV3sG3YsjSGT0IK20eyP9BEBZU2WL0
+7aNjrvR5aHxKc5FXsQJABsFtyGpgI5X4xufkJZVZ+Mklz2n7iXa+XPatMAHFxAtb
+EEMt60rngwMjXAzBSC6OYuYogRRAY3UCacNC5VhLYQ==
+-----END RSA PRIVATE KEY-----

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/root.crt
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/root.crt b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/root.crt
new file mode 100644
index 0000000..aecf8f6
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/root.crt
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIIEAzCCAuugAwIBAgIJANmheROCdW1NMA0GCSqGSIb3DQEBBQUAMF4xCzAJBgNV
+BAYTAlVTMQ8wDQYDVQQIEwZOZXZhZGExEjAQBgNVBAcTCUxhcyBWZWdhczEaMBgG
+A1UEChMRZ2l0aHViLmNvbS9saWIvcHExDjAMBgNVBAMTBXBxIENBMB4XDTE0MTAx
+MTE1MDQyOVoXDTI0MTAwODE1MDQyOVowXjELMAkGA1UEBhMCVVMxDzANBgNVBAgT
+Bk5ldmFkYTESMBAGA1UEBxMJTGFzIFZlZ2FzMRowGAYDVQQKExFnaXRodWIuY29t
+L2xpYi9wcTEOMAwGA1UEAxMFcHEgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
+ggEKAoIBAQCV4PxP7ShzWBzUCThcKk3qZtOLtHmszQVtbqhvgTpm1kTRtKBdVMu0
+pLAHQ3JgJCnAYgH0iZxVGoMP16T3irdgsdC48+nNTFM2T0cCdkfDURGIhSFN47cb
+Pgy306BcDUD2q7ucW33+dlFSRuGVewocoh4BWM/vMtMvvWzdi4Ag/L/jhb+5wZxZ
+sWymsadOVSDePEMKOvlCa3EdVwVFV40TVyDb+iWBUivDAYsS2a3KajuJrO6MbZiE
+Sp2RCIkZS2zFmzWxVRi9ZhzIZhh7EVF9JAaNC3T52jhGUdlRq3YpBTMnd89iOh74
+6jWXG7wSuPj3haFzyNhmJ0ZUh+2Ynoh1AgMBAAGjgcMwgcAwHQYDVR0OBBYEFFKT
+7R52Cp9lT94ZZsHVIkA1y6ByMIGQBgNVHSMEgYgwgYWAFFKT7R52Cp9lT94ZZsHV
+IkA1y6ByoWKkYDBeMQswCQYDVQQGEwJVUzEPMA0GA1UECBMGTmV2YWRhMRIwEAYD
+VQQHEwlMYXMgVmVnYXMxGjAYBgNVBAoTEWdpdGh1Yi5jb20vbGliL3BxMQ4wDAYD
+VQQDEwVwcSBDQYIJANmheROCdW1NMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEF
+BQADggEBAAEhCLWkqJNMI8b4gkbmj5fqQ/4+oO83bZ3w2Oqf6eZ8I8BC4f2NOyE6
+tRUlq5+aU7eqC1cOAvGjO+YHN/bF/DFpwLlzvUSXt+JP/pYcUjL7v+pIvwqec9hD
+ndvM4iIbkD/H/OYQ3L+N3W+G1x7AcFIX+bGCb3PzYVQAjxreV6//wgKBosMGFbZo
+HPxT9RPMun61SViF04H5TNs0derVn1+5eiiYENeAhJzQNyZoOOUuX1X/Inx9bEPh
+C5vFBtSMgIytPgieRJVWAiMLYsfpIAStrHztRAbBs2DU01LmMgRvHdxgFEKinC/d
+UHZZQDP+6pT+zADrGhQGXe4eThaO6f0=
+-----END CERTIFICATE-----

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.crt
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.crt b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.crt
new file mode 100644
index 0000000..ddc995a
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.crt
@@ -0,0 +1,81 @@
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        Serial Number: 1 (0x1)
+        Signature Algorithm: sha256WithRSAEncryption
+        Issuer: C=US, ST=Nevada, L=Las Vegas, O=github.com/lib/pq, CN=pq CA
+        Validity
+            Not Before: Oct 11 15:05:15 2014 GMT
+            Not After : Oct  8 15:05:15 2024 GMT
+        Subject: C=US, ST=Nevada, L=Las Vegas, O=github.com/lib/pq, CN=postgres
+        Subject Public Key Info:
+            Public Key Algorithm: rsaEncryption
+            RSA Public Key: (2048 bit)
+                Modulus (2048 bit):
+                    00:d7:8a:4c:85:fb:17:a5:3c:8f:e0:72:11:29:ce:
+                    3f:b0:1f:3f:7d:c6:ee:7f:a7:fc:02:2b:35:47:08:
+                    a6:3d:90:df:5c:56:14:94:00:c7:6d:d1:d2:e2:61:
+                    95:77:b8:e3:a6:66:31:f9:1f:21:7d:62:e1:27:da:
+                    94:37:61:4a:ea:63:53:a0:61:b8:9c:bb:a5:e2:e7:
+                    b7:a6:d8:0f:05:04:c7:29:e2:ea:49:2b:7f:de:15:
+                    00:a6:18:70:50:c7:0c:de:9a:f9:5a:96:b0:e1:94:
+                    06:c6:6d:4a:21:3b:b4:0f:a5:6d:92:86:34:b2:4e:
+                    d7:0e:a7:19:c0:77:0b:7b:87:c8:92:de:42:ff:86:
+                    d2:b7:9a:a4:d4:15:23:ca:ad:a5:69:21:b8:ce:7e:
+                    66:cb:85:5d:b9:ed:8b:2d:09:8d:94:e4:04:1e:72:
+                    ec:ef:d0:76:90:15:5a:a4:f7:91:4b:e9:ce:4e:9d:
+                    5d:9a:70:17:9c:d8:e9:73:83:ea:3d:61:99:a6:cd:
+                    ac:91:40:5a:88:77:e5:4e:2a:8e:3d:13:f3:f9:38:
+                    6f:81:6b:8a:95:ca:0e:07:ab:6f:da:b4:8c:d9:ff:
+                    aa:78:03:aa:c7:c2:cf:6f:64:92:d3:d8:83:d5:af:
+                    f1:23:18:a7:2e:7b:17:0b:e7:7d:f1:fa:a8:41:a3:
+                    04:57
+                Exponent: 65537 (0x10001)
+        X509v3 extensions:
+            X509v3 Subject Key Identifier: 
+                EE:F0:B3:46:DC:C7:09:EB:0E:B6:2F:E5:FE:62:60:45:44:9F:59:CC
+            X509v3 Authority Key Identifier: 
+                keyid:52:93:ED:1E:76:0A:9F:65:4F:DE:19:66:C1:D5:22:40:35:CB:A0:72
+
+            X509v3 Basic Constraints: 
+                CA:FALSE
+            X509v3 Key Usage: 
+                Digital Signature, Non Repudiation, Key Encipherment
+    Signature Algorithm: sha256WithRSAEncryption
+        7e:5a:6e:be:bf:d2:6c:c1:d6:fa:b6:fb:3f:06:53:36:08:87:
+        9d:95:b1:39:af:9e:f6:47:38:17:39:da:25:7c:f2:ad:0c:e3:
+        ab:74:19:ca:fb:8c:a0:50:c0:1d:19:8a:9c:21:ed:0f:3a:d1:
+        96:54:2e:10:09:4f:b8:70:f7:2b:99:43:d2:c6:15:bc:3f:24:
+        7d:28:39:32:3f:8d:a4:4f:40:75:7f:3e:0d:1c:d1:69:f2:4e:
+        98:83:47:97:d2:25:ac:c9:36:86:2f:04:a6:c4:86:c7:c4:00:
+        5f:7f:b9:ad:fc:bf:e9:f5:78:d7:82:1a:51:0d:fc:ab:9e:92:
+        1d:5f:0c:18:d1:82:e0:14:c9:ce:91:89:71:ff:49:49:ff:35:
+        bf:7b:44:78:42:c1:d0:66:65:bb:28:2e:60:ca:9b:20:12:a9:
+        90:61:b1:96:ec:15:46:c9:37:f7:07:90:8a:89:45:2a:3f:37:
+        ec:dc:e3:e5:8f:c3:3a:57:80:a5:54:60:0c:e1:b2:26:99:2b:
+        40:7e:36:d1:9a:70:02:ec:63:f4:3b:72:ae:81:fb:30:20:6d:
+        cb:48:46:c6:b5:8f:39:b1:84:05:25:55:8d:f5:62:f6:1b:46:
+        2e:da:a3:4c:26:12:44:d7:56:b6:b8:a9:ca:d3:ab:71:45:7c:
+        9f:48:6d:1e
+-----BEGIN CERTIFICATE-----
+MIIDlDCCAnygAwIBAgIBATANBgkqhkiG9w0BAQsFADBeMQswCQYDVQQGEwJVUzEP
+MA0GA1UECBMGTmV2YWRhMRIwEAYDVQQHEwlMYXMgVmVnYXMxGjAYBgNVBAoTEWdp
+dGh1Yi5jb20vbGliL3BxMQ4wDAYDVQQDEwVwcSBDQTAeFw0xNDEwMTExNTA1MTVa
+Fw0yNDEwMDgxNTA1MTVaMGExCzAJBgNVBAYTAlVTMQ8wDQYDVQQIEwZOZXZhZGEx
+EjAQBgNVBAcTCUxhcyBWZWdhczEaMBgGA1UEChMRZ2l0aHViLmNvbS9saWIvcHEx
+ETAPBgNVBAMTCHBvc3RncmVzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
+AQEA14pMhfsXpTyP4HIRKc4/sB8/fcbuf6f8Ais1RwimPZDfXFYUlADHbdHS4mGV
+d7jjpmYx+R8hfWLhJ9qUN2FK6mNToGG4nLul4ue3ptgPBQTHKeLqSSt/3hUAphhw
+UMcM3pr5Wpaw4ZQGxm1KITu0D6VtkoY0sk7XDqcZwHcLe4fIkt5C/4bSt5qk1BUj
+yq2laSG4zn5my4Vdue2LLQmNlOQEHnLs79B2kBVapPeRS+nOTp1dmnAXnNjpc4Pq
+PWGZps2skUBaiHflTiqOPRPz+ThvgWuKlcoOB6tv2rSM2f+qeAOqx8LPb2SS09iD
+1a/xIxinLnsXC+d98fqoQaMEVwIDAQABo1owWDAdBgNVHQ4EFgQU7vCzRtzHCesO
+ti/l/mJgRUSfWcwwHwYDVR0jBBgwFoAUUpPtHnYKn2VP3hlmwdUiQDXLoHIwCQYD
+VR0TBAIwADALBgNVHQ8EBAMCBeAwDQYJKoZIhvcNAQELBQADggEBAH5abr6/0mzB
+1vq2+z8GUzYIh52VsTmvnvZHOBc52iV88q0M46t0Gcr7jKBQwB0Zipwh7Q860ZZU
+LhAJT7hw9yuZQ9LGFbw/JH0oOTI/jaRPQHV/Pg0c0WnyTpiDR5fSJazJNoYvBKbE
+hsfEAF9/ua38v+n1eNeCGlEN/Kuekh1fDBjRguAUyc6RiXH/SUn/Nb97RHhCwdBm
+ZbsoLmDKmyASqZBhsZbsFUbJN/cHkIqJRSo/N+zc4+WPwzpXgKVUYAzhsiaZK0B+
+NtGacALsY/Q7cq6B+zAgbctIRsa1jzmxhAUlVY31YvYbRi7ao0wmEkTXVra4qcrT
+q3FFfJ9IbR4=
+-----END CERTIFICATE-----

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.key
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.key b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.key
new file mode 100644
index 0000000..bd7b019
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/certs/server.key
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEA14pMhfsXpTyP4HIRKc4/sB8/fcbuf6f8Ais1RwimPZDfXFYU
+lADHbdHS4mGVd7jjpmYx+R8hfWLhJ9qUN2FK6mNToGG4nLul4ue3ptgPBQTHKeLq
+SSt/3hUAphhwUMcM3pr5Wpaw4ZQGxm1KITu0D6VtkoY0sk7XDqcZwHcLe4fIkt5C
+/4bSt5qk1BUjyq2laSG4zn5my4Vdue2LLQmNlOQEHnLs79B2kBVapPeRS+nOTp1d
+mnAXnNjpc4PqPWGZps2skUBaiHflTiqOPRPz+ThvgWuKlcoOB6tv2rSM2f+qeAOq
+x8LPb2SS09iD1a/xIxinLnsXC+d98fqoQaMEVwIDAQABAoIBAF3ZoihUhJ82F4+r
+Gz4QyDpv4L1reT2sb1aiabhcU8ZK5nbWJG+tRyjSS/i2dNaEcttpdCj9HR/zhgZM
+bm0OuAgG58rVwgS80CZUruq++Qs+YVojq8/gWPTiQD4SNhV2Fmx3HkwLgUk3oxuT
+SsvdqzGE3okGVrutCIcgy126eA147VPMoej1Bb3fO6npqK0pFPhZfAc0YoqJuM+k
+obRm5pAnGUipyLCFXjA9HYPKwYZw2RtfdA3CiImHeanSdqS+ctrC9y8BV40Th7gZ
+haXdKUNdjmIxV695QQ1mkGqpKLZFqhzKioGQ2/Ly2d1iaKN9fZltTusu8unepWJ2
+tlT9qMECgYEA9uHaF1t2CqE+AJvWTihHhPIIuLxoOQXYea1qvxfcH/UMtaLKzCNm
+lQ5pqCGsPvp+10f36yttO1ZehIvlVNXuJsjt0zJmPtIolNuJY76yeussfQ9jHheB
+5uPEzCFlHzxYbBUyqgWaF6W74okRGzEGJXjYSP0yHPPdU4ep2q3bGiUCgYEA34Af
+wBSuQSK7uLxArWHvQhyuvi43ZGXls6oRGl+Ysj54s8BP6XGkq9hEJ6G4yxgyV+BR
+DUOs5X8/TLT8POuIMYvKTQthQyCk0eLv2FLdESDuuKx0kBVY3s8lK3/z5HhrdOiN
+VMNZU+xDKgKc3hN9ypkk8vcZe6EtH7Y14e0rVcsCgYBTgxi8F/M5K0wG9rAqphNz
+VFBA9XKn/2M33cKjO5X5tXIEKzpAjaUQvNxexG04rJGljzG8+mar0M6ONahw5yD1
+O7i/XWgazgpuOEkkVYiYbd8RutfDgR4vFVMn3hAP3eDnRtBplRWH9Ec3HTiNIys6
+F8PKBOQjyRZQQC7jyzW3hQKBgACe5HeuFwXLSOYsb6mLmhR+6+VPT4wR1F95W27N
+USk9jyxAnngxfpmTkiziABdgS9N+pfr5cyN4BP77ia/Jn6kzkC5Cl9SN5KdIkA3z
+vPVtN/x/ThuQU5zaymmig1ThGLtMYggYOslG4LDfLPxY5YKIhle+Y+259twdr2yf
+Mf2dAoGAaGv3tWMgnIdGRk6EQL/yb9PKHo7ShN+tKNlGaK7WwzBdKs+Fe8jkgcr7
+pz4Ne887CmxejdISzOCcdT+Zm9Bx6I/uZwWOtDvWpIgIxVX9a9URj/+D1MxTE/y4
+d6H+c89yDY62I2+drMpdjCd3EtCaTlxpTbRS+s1eAHMH7aEkcCE=
+-----END RSA PRIVATE KEY-----

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn.go
new file mode 100644
index 0000000..1725ab0
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn.go
@@ -0,0 +1,1821 @@
+package pq
+
+import (
+	"bufio"
+	"crypto/md5"
+	"database/sql"
+	"database/sql/driver"
+	"encoding/binary"
+	"errors"
+	"fmt"
+	"io"
+	"net"
+	"os"
+	"os/user"
+	"path"
+	"path/filepath"
+	"strconv"
+	"strings"
+	"time"
+	"unicode"
+
+	"github.com/lib/pq/oid"
+)
+
+// Common error types
+var (
+	ErrNotSupported              = errors.New("pq: Unsupported command")
+	ErrInFailedTransaction       = errors.New("pq: Could not complete operation in a failed transaction")
+	ErrSSLNotSupported           = errors.New("pq: SSL is not enabled on the server")
+	ErrSSLKeyHasWorldPermissions = errors.New("pq: Private key file has group or world access. Permissions should be u=rw (0600) or less")
+	ErrCouldNotDetectUsername    = errors.New("pq: Could not detect default username. Please provide one explicitly")
+
+	errUnexpectedReady = errors.New("unexpected ReadyForQuery")
+	errNoRowsAffected  = errors.New("no RowsAffected available after the empty statement")
+	errNoLastInsertID  = errors.New("no LastInsertId available after the empty statement")
+)
+
+type Driver struct{}
+
+func (d *Driver) Open(name string) (driver.Conn, error) {
+	return Open(name)
+}
+
+func init() {
+	sql.Register("postgres", &Driver{})
+}
+
+type parameterStatus struct {
+	// server version in the same format as server_version_num, or 0 if
+	// unavailable
+	serverVersion int
+
+	// the current location based on the TimeZone value of the session, if
+	// available
+	currentLocation *time.Location
+}
+
+type transactionStatus byte
+
+const (
+	txnStatusIdle                transactionStatus = 'I'
+	txnStatusIdleInTransaction   transactionStatus = 'T'
+	txnStatusInFailedTransaction transactionStatus = 'E'
+)
+
+func (s transactionStatus) String() string {
+	switch s {
+	case txnStatusIdle:
+		return "idle"
+	case txnStatusIdleInTransaction:
+		return "idle in transaction"
+	case txnStatusInFailedTransaction:
+		return "in a failed transaction"
+	default:
+		errorf("unknown transactionStatus %d", s)
+	}
+
+	panic("not reached")
+}
+
+type Dialer interface {
+	Dial(network, address string) (net.Conn, error)
+	DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)
+}
+
+type defaultDialer struct{}
+
+func (d defaultDialer) Dial(ntw, addr string) (net.Conn, error) {
+	return net.Dial(ntw, addr)
+}
+func (d defaultDialer) DialTimeout(ntw, addr string, timeout time.Duration) (net.Conn, error) {
+	return net.DialTimeout(ntw, addr, timeout)
+}
+
+type conn struct {
+	c         net.Conn
+	buf       *bufio.Reader
+	namei     int
+	scratch   [512]byte
+	txnStatus transactionStatus
+	txnFinish func()
+
+	// Save connection arguments to use during CancelRequest.
+	dialer Dialer
+	opts   values
+
+	// Cancellation key data for use with CancelRequest messages.
+	processID int
+	secretKey int
+
+	parameterStatus parameterStatus
+
+	saveMessageType   byte
+	saveMessageBuffer []byte
+
+	// If true, this connection is bad and all public-facing functions should
+	// return ErrBadConn.
+	bad bool
+
+	// If set, this connection should never use the binary format when
+	// receiving query results from prepared statements.  Only provided for
+	// debugging.
+	disablePreparedBinaryResult bool
+
+	// Whether to always send []byte parameters over as binary.  Enables single
+	// round-trip mode for non-prepared Query calls.
+	binaryParameters bool
+
+	// If true this connection is in the middle of a COPY
+	inCopy bool
+}
+
+// Handle driver-side settings in parsed connection string.
+func (cn *conn) handleDriverSettings(o values) (err error) {
+	boolSetting := func(key string, val *bool) error {
+		if value, ok := o[key]; ok {
+			if value == "yes" {
+				*val = true
+			} else if value == "no" {
+				*val = false
+			} else {
+				return fmt.Errorf("unrecognized value %q for %s", value, key)
+			}
+		}
+		return nil
+	}
+
+	err = boolSetting("disable_prepared_binary_result", &cn.disablePreparedBinaryResult)
+	if err != nil {
+		return err
+	}
+	err = boolSetting("binary_parameters", &cn.binaryParameters)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func (cn *conn) handlePgpass(o values) {
+	// if a password was supplied, do not process .pgpass
+	if _, ok := o["password"]; ok {
+		return
+	}
+	filename := os.Getenv("PGPASSFILE")
+	if filename == "" {
+		// XXX this code doesn't work on Windows where the default filename is
+		// XXX %APPDATA%\postgresql\pgpass.conf
+		user, err := user.Current()
+		if err != nil {
+			return
+		}
+		filename = filepath.Join(user.HomeDir, ".pgpass")
+	}
+	fileinfo, err := os.Stat(filename)
+	if err != nil {
+		return
+	}
+	mode := fileinfo.Mode()
+	if mode&(0x77) != 0 {
+		// XXX should warn about incorrect .pgpass permissions as psql does
+		return
+	}
+	file, err := os.Open(filename)
+	if err != nil {
+		return
+	}
+	defer file.Close()
+	scanner := bufio.NewScanner(io.Reader(file))
+	hostname := o["host"]
+	ntw, _ := network(o)
+	port := o["port"]
+	db := o["dbname"]
+	username := o["user"]
+	// From: https://github.com/tg/pgpass/blob/master/reader.go
+	getFields := func(s string) []string {
+		fs := make([]string, 0, 5)
+		f := make([]rune, 0, len(s))
+
+		var esc bool
+		for _, c := range s {
+			switch {
+			case esc:
+				f = append(f, c)
+				esc = false
+			case c == '\\':
+				esc = true
+			case c == ':':
+				fs = append(fs, string(f))
+				f = f[:0]
+			default:
+				f = append(f, c)
+			}
+		}
+		return append(fs, string(f))
+	}
+	for scanner.Scan() {
+		line := scanner.Text()
+		if len(line) == 0 || line[0] == '#' {
+			continue
+		}
+		split := getFields(line)
+		if len(split) != 5 {
+			continue
+		}
+		if (split[0] == "*" || split[0] == hostname || (split[0] == "localhost" && (hostname == "" || ntw == "unix"))) && (split[1] == "*" || split[1] == port) && (split[2] == "*" || split[2] == db) && (split[3] == "*" || split[3] == username) {
+			o["password"] = split[4]
+			return
+		}
+	}
+}
+
+func (cn *conn) writeBuf(b byte) *writeBuf {
+	cn.scratch[0] = b
+	return &writeBuf{
+		buf: cn.scratch[:5],
+		pos: 1,
+	}
+}
+
+func Open(name string) (_ driver.Conn, err error) {
+	return DialOpen(defaultDialer{}, name)
+}
+
+func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
+	// Handle any panics during connection initialization.  Note that we
+	// specifically do *not* want to use errRecover(), as that would turn any
+	// connection errors into ErrBadConns, hiding the real error message from
+	// the user.
+	defer errRecoverNoErrBadConn(&err)
+
+	o := make(values)
+
+	// A number of defaults are applied here, in this order:
+	//
+	// * Very low precedence defaults applied in every situation
+	// * Environment variables
+	// * Explicitly passed connection information
+	o["host"] = "localhost"
+	o["port"] = "5432"
+	// N.B.: Extra float digits should be set to 3, but that breaks
+	// Postgres 8.4 and older, where the max is 2.
+	o["extra_float_digits"] = "2"
+	for k, v := range parseEnviron(os.Environ()) {
+		o[k] = v
+	}
+
+	if strings.HasPrefix(name, "postgres://") || strings.HasPrefix(name, "postgresql://") {
+		name, err = ParseURL(name)
+		if err != nil {
+			return nil, err
+		}
+	}
+
+	if err := parseOpts(name, o); err != nil {
+		return nil, err
+	}
+
+	// Use the "fallback" application name if necessary
+	if fallback, ok := o["fallback_application_name"]; ok {
+		if _, ok := o["application_name"]; !ok {
+			o["application_name"] = fallback
+		}
+	}
+
+	// We can't work with any client_encoding other than UTF-8 currently.
+	// However, we have historically allowed the user to set it to UTF-8
+	// explicitly, and there's no reason to break such programs, so allow that.
+	// Note that the "options" setting could also set client_encoding, but
+	// parsing its value is not worth it.  Instead, we always explicitly send
+	// client_encoding as a separate run-time parameter, which should override
+	// anything set in options.
+	if enc, ok := o["client_encoding"]; ok && !isUTF8(enc) {
+		return nil, errors.New("client_encoding must be absent or 'UTF8'")
+	}
+	o["client_encoding"] = "UTF8"
+	// DateStyle needs a similar treatment.
+	if datestyle, ok := o["datestyle"]; ok {
+		if datestyle != "ISO, MDY" {
+			panic(fmt.Sprintf("setting datestyle must be absent or %v; got %v",
+				"ISO, MDY", datestyle))
+		}
+	} else {
+		o["datestyle"] = "ISO, MDY"
+	}
+
+	// If a user is not provided by any other means, the last
+	// resort is to use the current operating system provided user
+	// name.
+	if _, ok := o["user"]; !ok {
+		u, err := userCurrent()
+		if err != nil {
+			return nil, err
+		}
+		o["user"] = u
+	}
+
+	cn := &conn{
+		opts:   o,
+		dialer: d,
+	}
+	err = cn.handleDriverSettings(o)
+	if err != nil {
+		return nil, err
+	}
+	cn.handlePgpass(o)
+
+	cn.c, err = dial(d, o)
+	if err != nil {
+		return nil, err
+	}
+	cn.ssl(o)
+	cn.buf = bufio.NewReader(cn.c)
+	cn.startup(o)
+
+	// reset the deadline, in case one was set (see dial)
+	if timeout, ok := o["connect_timeout"]; ok && timeout != "0" {
+		err = cn.c.SetDeadline(time.Time{})
+	}
+	return cn, err
+}
+
+func dial(d Dialer, o values) (net.Conn, error) {
+	ntw, addr := network(o)
+	// SSL is not necessary or supported over UNIX domain sockets
+	if ntw == "unix" {
+		o["sslmode"] = "disable"
+	}
+
+	// Zero or not specified means wait indefinitely.
+	if timeout, ok := o["connect_timeout"]; ok && timeout != "0" {
+		seconds, err := strconv.ParseInt(timeout, 10, 0)
+		if err != nil {
+			return nil, fmt.Errorf("invalid value for parameter connect_timeout: %s", err)
+		}
+		duration := time.Duration(seconds) * time.Second
+		// connect_timeout should apply to the entire connection establishment
+		// procedure, so we both use a timeout for the TCP connection
+		// establishment and set a deadline for doing the initial handshake.
+		// The deadline is then reset after startup() is done.
+		deadline := time.Now().Add(duration)
+		conn, err := d.DialTimeout(ntw, addr, duration)
+		if err != nil {
+			return nil, err
+		}
+		err = conn.SetDeadline(deadline)
+		return conn, err
+	}
+	return d.Dial(ntw, addr)
+}
+
+func network(o values) (string, string) {
+	host := o["host"]
+
+	if strings.HasPrefix(host, "/") {
+		sockPath := path.Join(host, ".s.PGSQL."+o["port"])
+		return "unix", sockPath
+	}
+
+	return "tcp", net.JoinHostPort(host, o["port"])
+}
+
+type values map[string]string
+
+// scanner implements a tokenizer for libpq-style option strings.
+type scanner struct {
+	s []rune
+	i int
+}
+
+// newScanner returns a new scanner initialized with the option string s.
+func newScanner(s string) *scanner {
+	return &scanner{[]rune(s), 0}
+}
+
+// Next returns the next rune.
+// It returns 0, false if the end of the text has been reached.
+func (s *scanner) Next() (rune, bool) {
+	if s.i >= len(s.s) {
+		return 0, false
+	}
+	r := s.s[s.i]
+	s.i++
+	return r, true
+}
+
+// SkipSpaces returns the next non-whitespace rune.
+// It returns 0, false if the end of the text has been reached.
+func (s *scanner) SkipSpaces() (rune, bool) {
+	r, ok := s.Next()
+	for unicode.IsSpace(r) && ok {
+		r, ok = s.Next()
+	}
+	return r, ok
+}
+
+// parseOpts parses the options from name and adds them to the values.
+//
+// The parsing code is based on conninfo_parse from libpq's fe-connect.c
+func parseOpts(name string, o values) error {
+	s := newScanner(name)
+
+	for {
+		var (
+			keyRunes, valRunes []rune
+			r                  rune
+			ok                 bool
+		)
+
+		if r, ok = s.SkipSpaces(); !ok {
+			break
+		}
+
+		// Scan the key
+		for !unicode.IsSpace(r) && r != '=' {
+			keyRunes = append(keyRunes, r)
+			if r, ok = s.Next(); !ok {
+				break
+			}
+		}
+
+		// Skip any whitespace if we're not at the = yet
+		if r != '=' {
+			r, ok = s.SkipSpaces()
+		}
+
+		// The current character should be =
+		if r != '=' || !ok {
+			return fmt.Errorf(`missing "=" after %q in connection info string"`, string(keyRunes))
+		}
+
+		// Skip any whitespace after the =
+		if r, ok = s.SkipSpaces(); !ok {
+			// If we reach the end here, the last value is just an empty string as per libpq.
+			o[string(keyRunes)] = ""
+			break
+		}
+
+		if r != '\'' {
+			for !unicode.IsSpace(r) {
+				if r == '\\' {
+					if r, ok = s.Next(); !ok {
+						return fmt.Errorf(`missing character after backslash`)
+					}
+				}
+				valRunes = append(valRunes, r)
+
+				if r, ok = s.Next(); !ok {
+					break
+				}
+			}
+		} else {
+		quote:
+			for {
+				if r, ok = s.Next(); !ok {
+					return fmt.Errorf(`unterminated quoted string literal in connection string`)
+				}
+				switch r {
+				case '\'':
+					break quote
+				case '\\':
+					r, _ = s.Next()
+					fallthrough
+				default:
+					valRunes = append(valRunes, r)
+				}
+			}
+		}
+
+		o[string(keyRunes)] = string(valRunes)
+	}
+
+	return nil
+}
+
+func (cn *conn) isInTransaction() bool {
+	return cn.txnStatus == txnStatusIdleInTransaction ||
+		cn.txnStatus == txnStatusInFailedTransaction
+}
+
+func (cn *conn) checkIsInTransaction(intxn bool) {
+	if cn.isInTransaction() != intxn {
+		cn.bad = true
+		errorf("unexpected transaction status %v", cn.txnStatus)
+	}
+}
+
+func (cn *conn) Begin() (_ driver.Tx, err error) {
+	return cn.begin("")
+}
+
+func (cn *conn) begin(mode string) (_ driver.Tx, err error) {
+	if cn.bad {
+		return nil, driver.ErrBadConn
+	}
+	defer cn.errRecover(&err)
+
+	cn.checkIsInTransaction(false)
+	_, commandTag, err := cn.simpleExec("BEGIN" + mode)
+	if err != nil {
+		return nil, err
+	}
+	if commandTag != "BEGIN" {
+		cn.bad = true
+		return nil, fmt.Errorf("unexpected command tag %s", commandTag)
+	}
+	if cn.txnStatus != txnStatusIdleInTransaction {
+		cn.bad = true
+		return nil, fmt.Errorf("unexpected transaction status %v", cn.txnStatus)
+	}
+	return cn, nil
+}
+
+func (cn *conn) closeTxn() {
+	if finish := cn.txnFinish; finish != nil {
+		finish()
+	}
+}
+
+func (cn *conn) Commit() (err error) {
+	defer cn.closeTxn()
+	if cn.bad {
+		return driver.ErrBadConn
+	}
+	defer cn.errRecover(&err)
+
+	cn.checkIsInTransaction(true)
+	// We don't want the client to think that everything is okay if it tries
+	// to commit a failed transaction.  However, no matter what we return,
+	// database/sql will release this connection back into the free connection
+	// pool so we have to abort the current transaction here.  Note that you
+	// would get the same behaviour if you issued a COMMIT in a failed
+	// transaction, so it's also the least surprising thing to do here.
+	if cn.txnStatus == txnStatusInFailedTransaction {
+		if err := cn.Rollback(); err != nil {
+			return err
+		}
+		return ErrInFailedTransaction
+	}
+
+	_, commandTag, err := cn.simpleExec("COMMIT")
+	if err != nil {
+		if cn.isInTransaction() {
+			cn.bad = true
+		}
+		return err
+	}
+	if commandTag != "COMMIT" {
+		cn.bad = true
+		return fmt.Errorf("unexpected command tag %s", commandTag)
+	}
+	cn.checkIsInTransaction(false)
+	return nil
+}
+
+func (cn *conn) Rollback() (err error) {
+	defer cn.closeTxn()
+	if cn.bad {
+		return driver.ErrBadConn
+	}
+	defer cn.errRecover(&err)
+
+	cn.checkIsInTransaction(true)
+	_, commandTag, err := cn.simpleExec("ROLLBACK")
+	if err != nil {
+		if cn.isInTransaction() {
+			cn.bad = true
+		}
+		return err
+	}
+	if commandTag != "ROLLBACK" {
+		return fmt.Errorf("unexpected command tag %s", commandTag)
+	}
+	cn.checkIsInTransaction(false)
+	return nil
+}
+
+func (cn *conn) gname() string {
+	cn.namei++
+	return strconv.FormatInt(int64(cn.namei), 10)
+}
+
+func (cn *conn) simpleExec(q string) (res driver.Result, commandTag string, err error) {
+	b := cn.writeBuf('Q')
+	b.string(q)
+	cn.send(b)
+
+	for {
+		t, r := cn.recv1()
+		switch t {
+		case 'C':
+			res, commandTag = cn.parseComplete(r.string())
+		case 'Z':
+			cn.processReadyForQuery(r)
+			if res == nil && err == nil {
+				err = errUnexpectedReady
+			}
+			// done
+			return
+		case 'E':
+			err = parseError(r)
+		case 'I':
+			res = emptyRows
+		case 'T', 'D':
+			// ignore any results
+		default:
+			cn.bad = true
+			errorf("unknown response for simple query: %q", t)
+		}
+	}
+}
+
+func (cn *conn) simpleQuery(q string) (res *rows, err error) {
+	defer cn.errRecover(&err)
+
+	b := cn.writeBuf('Q')
+	b.string(q)
+	cn.send(b)
+
+	for {
+		t, r := cn.recv1()
+		switch t {
+		case 'C', 'I':
+			// We allow queries which don't return any results through Query as
+			// well as Exec.  We still have to give database/sql a rows object
+			// the user can close, though, to avoid connections from being
+			// leaked.  A "rows" with done=true works fine for that purpose.
+			if err != nil {
+				cn.bad = true
+				errorf("unexpected message %q in simple query execution", t)
+			}
+			if res == nil {
+				res = &rows{
+					cn: cn,
+				}
+			}
+			// Set the result and tag to the last command complete if there wasn't a
+			// query already run. Although queries usually return from here and cede
+			// control to Next, a query with zero results does not.
+			if t == 'C' && res.colNames == nil {
+				res.result, res.tag = cn.parseComplete(r.string())
+			}
+			res.done = true
+		case 'Z':
+			cn.processReadyForQuery(r)
+			// done
+			return
+		case 'E':
+			res = nil
+			err = parseError(r)
+		case 'D':
+			if res == nil {
+				cn.bad = true
+				errorf("unexpected DataRow in simple query execution")
+			}
+			// the query didn't fail; kick off to Next
+			cn.saveMessage(t, r)
+			return
+		case 'T':
+			// res might be non-nil here if we received a previous
+			// CommandComplete, but that's fine; just overwrite it
+			res = &rows{cn: cn}
+			res.colNames, res.colFmts, res.colTyps = parsePortalRowDescribe(r)
+
+			// To work around a bug in QueryRow in Go 1.2 and earlier, wait
+			// until the first DataRow has been received.
+		default:
+			cn.bad = true
+			errorf("unknown response for simple query: %q", t)
+		}
+	}
+}
+
+type noRows struct{}
+
+var emptyRows noRows
+
+var _ driver.Result = noRows{}
+
+func (noRows) LastInsertId() (int64, error) {
+	return 0, errNoLastInsertID
+}
+
+func (noRows) RowsAffected() (int64, error) {
+	return 0, errNoRowsAffected
+}
+
+// Decides which column formats to use for a prepared statement.  The input is
+// an array of type oids, one element per result column.
+func decideColumnFormats(colTyps []oid.Oid, forceText bool) (colFmts []format, colFmtData []byte) {
+	if len(colTyps) == 0 {
+		return nil, colFmtDataAllText
+	}
+
+	colFmts = make([]format, len(colTyps))
+	if forceText {
+		return colFmts, colFmtDataAllText
+	}
+
+	allBinary := true
+	allText := true
+	for i, o := range colTyps {
+		switch o {
+		// This is the list of types to use binary mode for when receiving them
+		// through a prepared statement.  If a type appears in this list, it
+		// must also be implemented in binaryDecode in encode.go.
+		case oid.T_bytea:
+			fallthrough
+		case oid.T_int8:
+			fallthrough
+		case oid.T_int4:
+			fallthrough
+		case oid.T_int2:
+			fallthrough
+		case oid.T_uuid:
+			colFmts[i] = formatBinary
+			allText = false
+
+		default:
+			allBinary = false
+		}
+	}
+
+	if allBinary {
+		return colFmts, colFmtDataAllBinary
+	} else if allText {
+		return colFmts, colFmtDataAllText
+	} else {
+		colFmtData = make([]byte, 2+len(colFmts)*2)
+		binary.BigEndian.PutUint16(colFmtData, uint16(len(colFmts)))
+		for i, v := range colFmts {
+			binary.BigEndian.PutUint16(colFmtData[2+i*2:], uint16(v))
+		}
+		return colFmts, colFmtData
+	}
+}
+
+func (cn *conn) prepareTo(q, stmtName string) *stmt {
+	st := &stmt{cn: cn, name: stmtName}
+
+	b := cn.writeBuf('P')
+	b.string(st.name)
+	b.string(q)
+	b.int16(0)
+
+	b.next('D')
+	b.byte('S')
+	b.string(st.name)
+
+	b.next('S')
+	cn.send(b)
+
+	cn.readParseResponse()
+	st.paramTyps, st.colNames, st.colTyps = cn.readStatementDescribeResponse()
+	st.colFmts, st.colFmtData = decideColumnFormats(st.colTyps, cn.disablePreparedBinaryResult)
+	cn.readReadyForQuery()
+	return st
+}
+
+func (cn *conn) Prepare(q string) (_ driver.Stmt, err error) {
+	if cn.bad {
+		return nil, driver.ErrBadConn
+	}
+	defer cn.errRecover(&err)
+
+	if len(q) >= 4 && strings.EqualFold(q[:4], "COPY") {
+		s, err := cn.prepareCopyIn(q)
+		if err == nil {
+			cn.inCopy = true
+		}
+		return s, err
+	}
+	return cn.prepareTo(q, cn.gname()), nil
+}
+
+func (cn *conn) Close() (err error) {
+	// Skip cn.bad return here because we always want to close a connection.
+	defer cn.errRecover(&err)
+
+	// Ensure that cn.c.Close is always run. Since error handling is done with
+	// panics and cn.errRecover, the Close must be in a defer.
+	defer func() {
+		cerr := cn.c.Close()
+		if err == nil {
+			err = cerr
+		}
+	}()
+
+	// Don't go through send(); ListenerConn relies on us not scribbling on the
+	// scratch buffer of this connection.
+	return cn.sendSimpleMessage('X')
+}
+
+// Implement the "Queryer" interface
+func (cn *conn) Query(query string, args []driver.Value) (driver.Rows, error) {
+	return cn.query(query, args)
+}
+
+func (cn *conn) query(query string, args []driver.Value) (_ *rows, err error) {
+	if cn.bad {
+		return nil, driver.ErrBadConn
+	}
+	if cn.inCopy {
+		return nil, errCopyInProgress
+	}
+	defer cn.errRecover(&err)
+
+	// Check to see if we can use the "simpleQuery" interface, which is
+	// *much* faster than going through prepare/exec
+	if len(args) == 0 {
+		return cn.simpleQuery(query)
+	}
+
+	if cn.binaryParameters {
+		cn.sendBinaryModeQuery(query, args)
+
+		cn.readParseResponse()
+		cn.readBindResponse()
+		rows := &rows{cn: cn}
+		rows.colNames, rows.colFmts, rows.colTyps = cn.readPortalDescribeResponse()
+		cn.postExecuteWorkaround()
+		return rows, nil
+	}
+	st := cn.prepareTo(query, "")
+	st.exec(args)
+	return &rows{
+		cn:       cn,
+		colNames: st.colNames,
+		colTyps:  st.colTyps,
+		colFmts:  st.colFmts,
+	}, nil
+}
+
+// Implement the optional "Execer" interface for one-shot queries
+func (cn *conn) Exec(query string, args []driver.Value) (res driver.Result, err error) {
+	if cn.bad {
+		return nil, driver.ErrBadConn
+	}
+	defer cn.errRecover(&err)
+
+	// Check to see if we can use the "simpleExec" interface, which is
+	// *much* faster than going through prepare/exec
+	if len(args) == 0 {
+		// ignore commandTag, our caller doesn't care
+		r, _, err := cn.simpleExec(query)
+		return r, err
+	}
+
+	if cn.binaryParameters {
+		cn.sendBinaryModeQuery(query, args)
+
+		cn.readParseResponse()
+		cn.readBindResponse()
+		cn.readPortalDescribeResponse()
+		cn.postExecuteWorkaround()
+		res, _, err = cn.readExecuteResponse("Execute")
+		return res, err
+	}
+	// Use the unnamed statement to defer planning until bind
+	// time, or else value-based selectivity estimates cannot be
+	// used.
+	st := cn.prepareTo(query, "")
+	r, err := st.Exec(args)
+	if err != nil {
+		panic(err)
+	}
+	return r, err
+}
+
+func (cn *conn) send(m *writeBuf) {
+	_, err := cn.c.Write(m.wrap())
+	if err != nil {
+		panic(err)
+	}
+}
+
+func (cn *conn) sendStartupPacket(m *writeBuf) error {
+	_, err := cn.c.Write((m.wrap())[1:])
+	return err
+}
+
+// Send a message of type typ to the server on the other end of cn.  The
+// message should have no payload.  This method does not use the scratch
+// buffer.
+func (cn *conn) sendSimpleMessage(typ byte) (err error) {
+	_, err = cn.c.Write([]byte{typ, '\x00', '\x00', '\x00', '\x04'})
+	return err
+}
+
+// saveMessage memorizes a message and its buffer in the conn struct.
+// recvMessage will then return these values on the next call to it.  This
+// method is useful in cases where you have to see what the next message is
+// going to be (e.g. to see whether it's an error or not) but you can't handle
+// the message yourself.
+func (cn *conn) saveMessage(typ byte, buf *readBuf) {
+	if cn.saveMessageType != 0 {
+		cn.bad = true
+		errorf("unexpected saveMessageType %d", cn.saveMessageType)
+	}
+	cn.saveMessageType = typ
+	cn.saveMessageBuffer = *buf
+}
+
+// recvMessage receives any message from the backend, or returns an error if
+// a problem occurred while reading the message.
+func (cn *conn) recvMessage(r *readBuf) (byte, error) {
+	// workaround for a QueryRow bug, see exec
+	if cn.saveMessageType != 0 {
+		t := cn.saveMessageType
+		*r = cn.saveMessageBuffer
+		cn.saveMessageType = 0
+		cn.saveMessageBuffer = nil
+		return t, nil
+	}
+
+	x := cn.scratch[:5]
+	_, err := io.ReadFull(cn.buf, x)
+	if err != nil {
+		return 0, err
+	}
+
+	// read the type and length of the message that follows
+	t := x[0]
+	n := int(binary.BigEndian.Uint32(x[1:])) - 4
+	var y []byte
+	if n <= len(cn.scratch) {
+		y = cn.scratch[:n]
+	} else {
+		y = make([]byte, n)
+	}
+	_, err = io.ReadFull(cn.buf, y)
+	if err != nil {
+		return 0, err
+	}
+	*r = y
+	return t, nil
+}
+
+// recv receives a message from the backend, but if an error happened while
+// reading the message or the received message was an ErrorResponse, it panics.
+// NoticeResponses are ignored.  This function should generally be used only
+// during the startup sequence.
+func (cn *conn) recv() (t byte, r *readBuf) {
+	for {
+		var err error
+		r = &readBuf{}
+		t, err = cn.recvMessage(r)
+		if err != nil {
+			panic(err)
+		}
+
+		switch t {
+		case 'E':
+			panic(parseError(r))
+		case 'N':
+			// ignore
+		default:
+			return
+		}
+	}
+}
+
+// recv1Buf is exactly equivalent to recv1, except it uses a buffer supplied by
+// the caller to avoid an allocation.
+func (cn *conn) recv1Buf(r *readBuf) byte {
+	for {
+		t, err := cn.recvMessage(r)
+		if err != nil {
+			panic(err)
+		}
+
+		switch t {
+		case 'A', 'N':
+			// ignore
+		case 'S':
+			cn.processParameterStatus(r)
+		default:
+			return t
+		}
+	}
+}
+
+// recv1 receives a message from the backend, panicking if an error occurs
+// while attempting to read it.  All asynchronous messages are ignored, with
+// the exception of ErrorResponse.
+func (cn *conn) recv1() (t byte, r *readBuf) {
+	r = &readBuf{}
+	t = cn.recv1Buf(r)
+	return t, r
+}
+
+func (cn *conn) ssl(o values) {
+	upgrade := ssl(o)
+	if upgrade == nil {
+		// Nothing to do
+		return
+	}
+
+	w := cn.writeBuf(0)
+	w.int32(80877103)
+	if err := cn.sendStartupPacket(w); err != nil {
+		panic(err)
+	}
+
+	b := cn.scratch[:1]
+	_, err := io.ReadFull(cn.c, b)
+	if err != nil {
+		panic(err)
+	}
+
+	if b[0] != 'S' {
+		panic(ErrSSLNotSupported)
+	}
+
+	cn.c = upgrade(cn.c)
+}
+
+// isDriverSetting returns true iff a setting is purely for configuring the
+// driver's options and should not be sent to the server in the connection
+// startup packet.
+func isDriverSetting(key string) bool {
+	switch key {
+	case "host", "port":
+		return true
+	case "password":
+		return true
+	case "sslmode", "sslcert", "sslkey", "sslrootcert":
+		return true
+	case "fallback_application_name":
+		return true
+	case "connect_timeout":
+		return true
+	case "disable_prepared_binary_result":
+		return true
+	case "binary_parameters":
+		return true
+
+	default:
+		return false
+	}
+}
+
+func (cn *conn) startup(o values) {
+	w := cn.writeBuf(0)
+	w.int32(196608)
+	// Send the backend the name of the database we want to connect to, and the
+	// user we want to connect as.  Additionally, we send over any run-time
+	// parameters potentially included in the connection string.  If the server
+	// doesn't recognize any of them, it will reply with an error.
+	for k, v := range o {
+		if isDriverSetting(k) {
+			// skip options which can't be run-time parameters
+			continue
+		}
+		// The protocol requires us to supply the database name as "database"
+		// instead of "dbname".
+		if k == "dbname" {
+			k = "database"
+		}
+		w.string(k)
+		w.string(v)
+	}
+	w.string("")
+	if err := cn.sendStartupPacket(w); err != nil {
+		panic(err)
+	}
+
+	for {
+		t, r := cn.recv()
+		switch t {
+		case 'K':
+			cn.processBackendKeyData(r)
+		case 'S':
+			cn.processParameterStatus(r)
+		case 'R':
+			cn.auth(r, o)
+		case 'Z':
+			cn.processReadyForQuery(r)
+			return
+		default:
+			errorf("unknown response for startup: %q", t)
+		}
+	}
+}
+
+func (cn *conn) auth(r *readBuf, o values) {
+	switch code := r.int32(); code {
+	case 0:
+		// OK
+	case 3:
+		w := cn.writeBuf('p')
+		w.string(o["password"])
+		cn.send(w)
+
+		t, r := cn.recv()
+		if t != 'R' {
+			errorf("unexpected password response: %q", t)
+		}
+
+		if r.int32() != 0 {
+			errorf("unexpected authentication response: %q", t)
+		}
+	case 5:
+		s := string(r.next(4))
+		w := cn.writeBuf('p')
+		w.string("md5" + md5s(md5s(o["password"]+o["user"])+s))
+		cn.send(w)
+
+		t, r := cn.recv()
+		if t != 'R' {
+			errorf("unexpected password response: %q", t)
+		}
+
+		if r.int32() != 0 {
+			errorf("unexpected authentication response: %q", t)
+		}
+	default:
+		errorf("unknown authentication response: %d", code)
+	}
+}
+
+type format int
+
+const formatText format = 0
+const formatBinary format = 1
+
+// One result-column format code with the value 1 (i.e. all binary).
+var colFmtDataAllBinary = []byte{0, 1, 0, 1}
+
+// No result-column format codes (i.e. all text).
+var colFmtDataAllText = []byte{0, 0}
+
+type stmt struct {
+	cn         *conn
+	name       string
+	colNames   []string
+	colFmts    []format
+	colFmtData []byte
+	colTyps    []oid.Oid
+	paramTyps  []oid.Oid
+	closed     bool
+}
+
+func (st *stmt) Close() (err error) {
+	if st.closed {
+		return nil
+	}
+	if st.cn.bad {
+		return driver.ErrBadConn
+	}
+	defer st.cn.errRecover(&err)
+
+	w := st.cn.writeBuf('C')
+	w.byte('S')
+	w.string(st.name)
+	st.cn.send(w)
+
+	st.cn.send(st.cn.writeBuf('S'))
+
+	t, _ := st.cn.recv1()
+	if t != '3' {
+		st.cn.bad = true
+		errorf("unexpected close response: %q", t)
+	}
+	st.closed = true
+
+	t, r := st.cn.recv1()
+	if t != 'Z' {
+		st.cn.bad = true
+		errorf("expected ready for query, but got: %q", t)
+	}
+	st.cn.processReadyForQuery(r)
+
+	return nil
+}
+
+func (st *stmt) Query(v []driver.Value) (r driver.Rows, err error) {
+	if st.cn.bad {
+		return nil, driver.ErrBadConn
+	}
+	defer st.cn.errRecover(&err)
+
+	st.exec(v)
+	return &rows{
+		cn:       st.cn,
+		colNames: st.colNames,
+		colTyps:  st.colTyps,
+		colFmts:  st.colFmts,
+	}, nil
+}
+
+func (st *stmt) Exec(v []driver.Value) (res driver.Result, err error) {
+	if st.cn.bad {
+		return nil, driver.ErrBadConn
+	}
+	defer st.cn.errRecover(&err)
+
+	st.exec(v)
+	res, _, err = st.cn.readExecuteResponse("simple query")
+	return res, err
+}
+
+func (st *stmt) exec(v []driver.Value) {
+	if len(v) >= 65536 {
+		errorf("got %d parameters but PostgreSQL only supports 65535 parameters", len(v))
+	}
+	if len(v) != len(st.paramTyps) {
+		errorf("got %d parameters but the statement requires %d", len(v), len(st.paramTyps))
+	}
+
+	cn := st.cn
+	w := cn.writeBuf('B')
+	w.byte(0) // unnamed portal
+	w.string(st.name)
+
+	if cn.binaryParameters {
+		cn.sendBinaryParameters(w, v)
+	} else {
+		w.int16(0)
+		w.int16(len(v))
+		for i, x := range v {
+			if x == nil {
+				w.int32(-1)
+			} else {
+				b := encode(&cn.parameterStatus, x, st.paramTyps[i])
+				w.int32(len(b))
+				w.bytes(b)
+			}
+		}
+	}
+	w.bytes(st.colFmtData)
+
+	w.next('E')
+	w.byte(0)
+	w.int32(0)
+
+	w.next('S')
+	cn.send(w)
+
+	cn.readBindResponse()
+	cn.postExecuteWorkaround()
+
+}
+
+func (st *stmt) NumInput() int {
+	return len(st.paramTyps)
+}
+
+// parseComplete parses the "command tag" from a CommandComplete message, and
+// returns the number of rows affected (if applicable) and a string
+// identifying only the command that was executed, e.g. "ALTER TABLE".  If the
+// command tag could not be parsed, parseComplete panics.
+func (cn *conn) parseComplete(commandTag string) (driver.Result, string) {
+	commandsWithAffectedRows := []string{
+		"SELECT ",
+		// INSERT is handled below
+		"UPDATE ",
+		"DELETE ",
+		"FETCH ",
+		"MOVE ",
+		"COPY ",
+	}
+
+	var affectedRows *string
+	for _, tag := range commandsWithAffectedRows {
+		if strings.HasPrefix(commandTag, tag) {
+			t := commandTag[len(tag):]
+			affectedRows = &t
+			commandTag = tag[:len(tag)-1]
+			break
+		}
+	}
+	// INSERT also includes the oid of the inserted row in its command tag.
+	// Oids in user tables are deprecated, and the oid is only returned when
+	// exactly one row is inserted, so it's unlikely to be of value to any
+	// real-world application and we can ignore it.
+	if affectedRows == nil && strings.HasPrefix(commandTag, "INSERT ") {
+		parts := strings.Split(commandTag, " ")
+		if len(parts) != 3 {
+			cn.bad = true
+			errorf("unexpected INSERT command tag %s", commandTag)
+		}
+		affectedRows = &parts[len(parts)-1]
+		commandTag = "INSERT"
+	}
+	// There should be no affected rows attached to the tag, just return it
+	if affectedRows == nil {
+		return driver.RowsAffected(0), commandTag
+	}
+	n, err := strconv.ParseInt(*affectedRows, 10, 64)
+	if err != nil {
+		cn.bad = true
+		errorf("could not parse commandTag: %s", err)
+	}
+	return driver.RowsAffected(n), commandTag
+}
+
+type rows struct {
+	cn       *conn
+	finish   func()
+	colNames []string
+	colTyps  []oid.Oid
+	colFmts  []format
+	done     bool
+	rb       readBuf
+	result   driver.Result
+	tag      string
+}
+
+func (rs *rows) Close() error {
+	if finish := rs.finish; finish != nil {
+		defer finish()
+	}
+	// no need to look at cn.bad as Next() will
+	for {
+		err := rs.Next(nil)
+		switch err {
+		case nil:
+		case io.EOF:
+			// rs.Next can return io.EOF on both 'Z' (ready for query) and 'T' (row
+			// description, used with HasNextResultSet). We need to fetch messages until
+			// we hit a 'Z', which is done by waiting for done to be set.
+			if rs.done {
+				return nil
+			}
+		default:
+			return err
+		}
+	}
+}
+
+func (rs *rows) Columns() []string {
+	return rs.colNames
+}
+
+func (rs *rows) Result() driver.Result {
+	if rs.result == nil {
+		return emptyRows
+	}
+	return rs.result
+}
+
+func (rs *rows) Tag() string {
+	return rs.tag
+}
+
+func (rs *rows) Next(dest []driver.Value) (err error) {
+	if rs.done {
+		return io.EOF
+	}
+
+	conn := rs.cn
+	if conn.bad {
+		return driver.ErrBadConn
+	}
+	defer conn.errRecover(&err)
+
+	for {
+		t := conn.recv1Buf(&rs.rb)
+		switch t {
+		case 'E':
+			err = parseError(&rs.rb)
+		case 'C', 'I':
+			if t == 'C' {
+				rs.result, rs.tag = conn.parseComplete(rs.rb.string())
+			}
+			continue
+		case 'Z':
+			conn.processReadyForQuery(&rs.rb)
+			rs.done = true
+			if err != nil {
+				return err
+			}
+			return io.EOF
+		case 'D':
+			n := rs.rb.int16()
+			if err != nil {
+				conn.bad = true
+				errorf("unexpected DataRow after error %s", err)
+			}
+			if n < len(dest) {
+				dest = dest[:n]
+			}
+			for i := range dest {
+				l := rs.rb.int32()
+				if l == -1 {
+					dest[i] = nil
+					continue
+				}
+				dest[i] = decode(&conn.parameterStatus, rs.rb.next(l), rs.colTyps[i], rs.colFmts[i])
+			}
+			return
+		case 'T':
+			rs.colNames, rs.colFmts, rs.colTyps = parsePortalRowDescribe(&rs.rb)
+			return io.EOF
+		default:
+			errorf("unexpected message after execute: %q", t)
+		}
+	}
+}
+
+func (rs *rows) HasNextResultSet() bool {
+	return !rs.done
+}
+
+func (rs *rows) NextResultSet() error {
+	return nil
+}
+
+// QuoteIdentifier quotes an "identifier" (e.g. a table or a column name) to be
+// used as part of an SQL statement.  For example:
+//
+//    tblname := "my_table"
+//    data := "my_data"
+//    err = db.Exec(fmt.Sprintf("INSERT INTO %s VALUES ($1)", pq.QuoteIdentifier(tblname)), data)
+//
+// Any double quotes in name will be escaped.  The quoted identifier will be
+// case sensitive when used in a query.  If the input string contains a zero
+// byte, the result will be truncated immediately before it.
+func QuoteIdentifier(name string) string {
+	end := strings.IndexRune(name, 0)
+	if end > -1 {
+		name = name[:end]
+	}
+	return `"` + strings.Replace(name, `"`, `""`, -1) + `"`
+}
+
+func md5s(s string) string {
+	h := md5.New()
+	h.Write([]byte(s))
+	return fmt.Sprintf("%x", h.Sum(nil))
+}
+
+func (cn *conn) sendBinaryParameters(b *writeBuf, args []driver.Value) {
+	// Do one pass over the parameters to see if we're going to send any of
+	// them over in binary.  If we are, create a paramFormats array at the
+	// same time.
+	var paramFormats []int
+	for i, x := range args {
+		_, ok := x.([]byte)
+		if ok {
+			if paramFormats == nil {
+				paramFormats = make([]int, len(args))
+			}
+			paramFormats[i] = 1
+		}
+	}
+	if paramFormats == nil {
+		b.int16(0)
+	} else {
+		b.int16(len(paramFormats))
+		for _, x := range paramFormats {
+			b.int16(x)
+		}
+	}
+
+	b.int16(len(args))
+	for _, x := range args {
+		if x == nil {
+			b.int32(-1)
+		} else {
+			datum := binaryEncode(&cn.parameterStatus, x)
+			b.int32(len(datum))
+			b.bytes(datum)
+		}
+	}
+}
+
+func (cn *conn) sendBinaryModeQuery(query string, args []driver.Value) {
+	if len(args) >= 65536 {
+		errorf("got %d parameters but PostgreSQL only supports 65535 parameters", len(args))
+	}
+
+	b := cn.writeBuf('P')
+	b.byte(0) // unnamed statement
+	b.string(query)
+	b.int16(0)
+
+	b.next('B')
+	b.int16(0) // unnamed portal and statement
+	cn.sendBinaryParameters(b, args)
+	b.bytes(colFmtDataAllText)
+
+	b.next('D')
+	b.byte('P')
+	b.byte(0) // unnamed portal
+
+	b.next('E')
+	b.byte(0)
+	b.int32(0)
+
+	b.next('S')
+	cn.send(b)
+}
+
+func (cn *conn) processParameterStatus(r *readBuf) {
+	var err error
+
+	param := r.string()
+	switch param {
+	case "server_version":
+		var major1 int
+		var major2 int
+		var minor int
+		_, err = fmt.Sscanf(r.string(), "%d.%d.%d", &major1, &major2, &minor)
+		if err == nil {
+			cn.parameterStatus.serverVersion = major1*10000 + major2*100 + minor
+		}
+
+	case "TimeZone":
+		cn.parameterStatus.currentLocation, err = time.LoadLocation(r.string())
+		if err != nil {
+			cn.parameterStatus.currentLocation = nil
+		}
+
+	default:
+		// ignore
+	}
+}
+
+func (cn *conn) processReadyForQuery(r *readBuf) {
+	cn.txnStatus = transactionStatus(r.byte())
+}
+
+func (cn *conn) readReadyForQuery() {
+	t, r := cn.recv1()
+	switch t {
+	case 'Z':
+		cn.processReadyForQuery(r)
+		return
+	default:
+		cn.bad = true
+		errorf("unexpected message %q; expected ReadyForQuery", t)
+	}
+}
+
+func (cn *conn) processBackendKeyData(r *readBuf) {
+	cn.processID = r.int32()
+	cn.secretKey = r.int32()
+}
+
+func (cn *conn) readParseResponse() {
+	t, r := cn.recv1()
+	switch t {
+	case '1':
+		return
+	case 'E':
+		err := parseError(r)
+		cn.readReadyForQuery()
+		panic(err)
+	default:
+		cn.bad = true
+		errorf("unexpected Parse response %q", t)
+	}
+}
+
+func (cn *conn) readStatementDescribeResponse() (paramTyps []oid.Oid, colNames []string, colTyps []oid.Oid) {
+	for {
+		t, r := cn.recv1()
+		switch t {
+		case 't':
+			nparams := r.int16()
+			paramTyps = make([]oid.Oid, nparams)
+			for i := range paramTyps {
+				paramTyps[i] = r.oid()
+			}
+		case 'n':
+			return paramTyps, nil, nil
+		case 'T':
+			colNames, colTyps = parseStatementRowDescribe(r)
+			return paramTyps, colNames, colTyps
+		case 'E':
+			err := parseError(r)
+			cn.readReadyForQuery()
+			panic(err)
+		default:
+			cn.bad = true
+			errorf("unexpected Describe statement response %q", t)
+		}
+	}
+}
+
+func (cn *conn) readPortalDescribeResponse() (colNames []string, colFmts []format, colTyps []oid.Oid) {
+	t, r := cn.recv1()
+	switch t {
+	case 'T':
+		return parsePortalRowDescribe(r)
+	case 'n':
+		return nil, nil, nil
+	case 'E':
+		err := parseError(r)
+		cn.readReadyForQuery()
+		panic(err)
+	default:
+		cn.bad = true
+		errorf("unexpected Describe response %q", t)
+	}
+	panic("not reached")
+}
+
+func (cn *conn) readBindResponse() {
+	t, r := cn.recv1()
+	switch t {
+	case '2':
+		return
+	case 'E':
+		err := parseError(r)
+		cn.readReadyForQuery()
+		panic(err)
+	default:
+		cn.bad = true
+		errorf("unexpected Bind response %q", t)
+	}
+}
+
+func (cn *conn) postExecuteWorkaround() {
+	// Work around a bug in sql.DB.QueryRow: in Go 1.2 and earlier it ignores
+	// any errors from rows.Next, which masks errors that happened during the
+	// execution of the query.  To avoid the problem in common cases, we wait
+	// here for one more message from the database.  If it's not an error the
+	// query will likely succeed (or perhaps has already, if it's a
+	// CommandComplete), so we push the message into the conn struct; recv1
+	// will return it as the next message for rows.Next or rows.Close.
+	// However, if it's an error, we wait until ReadyForQuery and then return
+	// the error to our caller.
+	for {
+		t, r := cn.recv1()
+		switch t {
+		case 'E':
+			err := parseError(r)
+			cn.readReadyForQuery()
+			panic(err)
+		case 'C', 'D', 'I':
+			// the query didn't fail, but we can't process this message
+			cn.saveMessage(t, r)
+			return
+		default:
+			cn.bad = true
+			errorf("unexpected message during extended query execution: %q", t)
+		}
+	}
+}
+
+// Only for Exec(), since we ignore the returned data
+func (cn *conn) readExecuteResponse(protocolState string) (res driver.Result, commandTag string, err error) {
+	for {
+		t, r := cn.recv1()
+		switch t {
+		case 'C':
+			if err != nil {
+				cn.bad = true
+				errorf("unexpected CommandComplete after error %s", err)
+			}
+			res, commandTag = cn.parseComplete(r.string())
+		case 'Z':
+			cn.processReadyForQuery(r)
+			if res == nil && err == nil {
+				err = errUnexpectedReady
+			}
+			return res, commandTag, err
+		case 'E':
+			err = parseError(r)
+		case 'T', 'D', 'I':
+			if err != nil {
+				cn.bad = true
+				errorf("unexpected %q after error %s", t, err)
+			}
+			if t == 'I' {
+				res = emptyRows
+			}
+			// ignore any results
+		default:
+			cn.bad = true
+			errorf("unknown %s response: %q", protocolState, t)
+		}
+	}
+}
+
+func parseStatementRowDescribe(r *readBuf) (colNames []string, colTyps []oid.Oid) {
+	n := r.int16()
+	colNames = make([]string, n)
+	colTyps = make([]oid.Oid, n)
+	for i := range colNames {
+		colNames[i] = r.string()
+		r.next(6)
+		colTyps[i] = r.oid()
+		r.next(6)
+		// format code not known when describing a statement; always 0
+		r.next(2)
+	}
+	return
+}
+
+func parsePortalRowDescribe(r *readBuf) (colNames []string, colFmts []format, colTyps []oid.Oid) {
+	n := r.int16()
+	colNames = make([]string, n)
+	colFmts = make([]format, n)
+	colTyps = make([]oid.Oid, n)
+	for i := range colNames {
+		colNames[i] = r.string()
+		r.next(6)
+		colTyps[i] = r.oid()
+		r.next(6)
+		colFmts[i] = format(r.int16())
+	}
+	return
+}
+
+// parseEnviron tries to mimic some of libpq's environment handling
+//
+// To ease testing, it does not directly reference os.Environ, but is
+// designed to accept its output.
+//
+// Environment-set connection information is intended to have a higher
+// precedence than a library default but lower than any explicitly
+// passed information (such as in the URL or connection string).
+func parseEnviron(env []string) (out map[string]string) {
+	out = make(map[string]string)
+
+	for _, v := range env {
+		parts := strings.SplitN(v, "=", 2)
+
+		accrue := func(keyname string) {
+			out[keyname] = parts[1]
+		}
+		unsupported := func() {
+			panic(fmt.Sprintf("setting %v not supported", parts[0]))
+		}
+
+		// The order of these is the same as is seen in the
+		// PostgreSQL 9.1 manual. Unsupported but well-defined
+		// keys cause a panic; these should be unset prior to
+		// execution. Options which pq expects to be set to a
+		// certain value are allowed, but must be set to that
+		// value if present (they can, of course, be absent).
+		switch parts[0] {
+		case "PGHOST":
+			accrue("host")
+		case "PGHOSTADDR":
+			unsupported()
+		case "PGPORT":
+			accrue("port")
+		case "PGDATABASE":
+			accrue("dbname")
+		case "PGUSER":
+			accrue("user")
+		case "PGPASSWORD":
+			accrue("password")
+		case "PGSERVICE", "PGSERVICEFILE", "PGREALM":
+			unsupported()
+		case "PGOPTIONS":
+			accrue("options")
+		case "PGAPPNAME":
+			accrue("application_name")
+		case "PGSSLMODE":
+			accrue("sslmode")
+		case "PGSSLCERT":
+			accrue("sslcert")
+		case "PGSSLKEY":
+			accrue("sslkey")
+		case "PGSSLROOTCERT":
+			accrue("sslrootcert")
+		case "PGREQUIRESSL", "PGSSLCRL":
+			unsupported()
+		case "PGREQUIREPEER":
+			unsupported()
+		case "PGKRBSRVNAME", "PGGSSLIB":
+			unsupported()
+		case "PGCONNECT_TIMEOUT":
+			accrue("connect_timeout")
+		case "PGCLIENTENCODING":
+			accrue("client_encoding")
+		case "PGDATESTYLE":
+			accrue("datestyle")
+		case "PGTZ":
+			accrue("timezone")
+		case "PGGEQO":
+			accrue("geqo")
+		case "PGSYSCONFDIR", "PGLOCALEDIR":
+			unsupported()
+		}
+	}
+
+	return out
+}
+
+// isUTF8 returns whether name is a fuzzy variation of the string "UTF-8".
+func isUTF8(name string) bool {
+	// Recognize all sorts of silly things as "UTF-8", like Postgres does
+	s := strings.Map(alnumLowerASCII, name)
+	return s == "utf8" || s == "unicode"
+}
+
+func alnumLowerASCII(ch rune) rune {
+	if 'A' <= ch && ch <= 'Z' {
+		return ch + ('a' - 'A')
+	}
+	if 'a' <= ch && ch <= 'z' || '0' <= ch && ch <= '9' {
+		return ch
+	}
+	return -1 // discard
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_go18.go b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_go18.go
new file mode 100644
index 0000000..ab97a10
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/github.com/lib/pq/conn_go18.go
@@ -0,0 +1,128 @@
+// +build go1.8
+
+package pq
+
+import (
+	"context"
+	"database/sql"
+	"database/sql/driver"
+	"fmt"
+	"io"
+	"io/ioutil"
+)
+
+// Implement the "QueryerContext" interface
+func (cn *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
+	list := make([]driver.Value, len(args))
+	for i, nv := range args {
+		list[i] = nv.Value
+	}
+	finish := cn.watchCancel(ctx)
+	r, err := cn.query(query, list)
+	if err != nil {
+		if finish != nil {
+			finish()
+		}
+		return nil, err
+	}
+	r.finish = finish
+	return r, nil
+}
+
+// Implement the "ExecerContext" interface
+func (cn *conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
+	list := make([]driver.Value, len(args))
+	for i, nv := range args {
+		list[i] = nv.Value
+	}
+
+	if finish := cn.watchCancel(ctx); finish != nil {
+		defer finish()
+	}
+
+	return cn.Exec(query, list)
+}
+
+// Implement the "ConnBeginTx" interface
+func (cn *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
+	var mode string
+
+	switch sql.IsolationLevel(opts.Isolation) {
+	case sql.LevelDefault:
+		// Don't touch mode: use the server's default
+	case sql.LevelReadUncommitted:
+		mode = " ISOLATION LEVEL READ UNCOMMITTED"
+	case sql.LevelReadCommitted:
+		mode = " ISOLATION LEVEL READ COMMITTED"
+	case sql.LevelRepeatableRead:
+		mode = " ISOLATION LEVEL REPEATABLE READ"
+	case sql.LevelSerializable:
+		mode = " ISOLATION LEVEL SERIALIZABLE"
+	default:
+		return nil, fmt.Errorf("pq: isolation level not supported: %d", opts.Isolation)
+	}
+
+	if opts.ReadOnly {
+		mode += " READ ONLY"
+	} else {
+		mode += " READ WRITE"
+	}
+
+	tx, err := cn.begin(mode)
+	if err != nil {
+		return nil, err
+	}
+	cn.txnFinish = cn.watchCancel(ctx)
+	return tx, nil
+}
+
+func (cn *conn) watchCancel(ctx context.Context) func() {
+	if done := ctx.Done(); done != nil {
+		finished := make(chan struct{})
+		go func() {
+			select {
+			case <-done:
+				_ = cn.cancel()
+				finished <- struct{}{}
+			case <-finished:
+			}
+		}()
+		return func() {
+			select {
+			case <-finished:
+			case finished <- struct{}{}:
+			}
+		}
+	}
+	return nil
+}
+
+func (cn *conn) cancel() error {
+	c, err := dial(cn.dialer, cn.opts)
+	if err != nil {
+		return err
+	}
+	defer c.Close()
+
+	{
+		can := conn{
+			c: c,
+		}
+		can.ssl(cn.opts)
+
+		w := can.writeBuf(0)
+		w.int32(80877102) // cancel request code
+		w.int32(cn.processID)
+		w.int32(cn.secretKey)
+
+		if err := can.sendStartupPacket(w); err != nil {
+			return err
+		}
+	}
+
+	// Read until EOF to ensure that the server received the cancel.
+	{
+		_, err := io.Copy(ioutil.Discard, c)
+		return err
+	}
+}


[2/9] incubator-trafficcontrol git commit: added lib/pq to the vendor dir and renamed the go-sqlmock to its version

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_test.go
new file mode 100644
index 0000000..fe4924b
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/sqlmock_test.go
@@ -0,0 +1,998 @@
+package sqlmock
+
+import (
+	"database/sql"
+	"fmt"
+	"strconv"
+	"sync"
+	"testing"
+	"time"
+)
+
+func cancelOrder(db *sql.DB, orderID int) error {
+	tx, _ := db.Begin()
+	_, _ = tx.Query("SELECT * FROM orders {0} FOR UPDATE", orderID)
+	err := tx.Rollback()
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func Example() {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	// columns to be used for result
+	columns := []string{"id", "status"}
+	// expect transaction begin
+	mock.ExpectBegin()
+	// expect query to fetch order, match it with regexp
+	mock.ExpectQuery("SELECT (.+) FROM orders (.+) FOR UPDATE").
+		WithArgs(1).
+		WillReturnRows(NewRows(columns).AddRow(1, 1))
+	// expect transaction rollback, since order status is "cancelled"
+	mock.ExpectRollback()
+
+	// run the cancel order function
+	someOrderID := 1
+	// call a function which executes expected database operations
+	err = cancelOrder(db, someOrderID)
+	if err != nil {
+		fmt.Printf("unexpected error: %s", err)
+		return
+	}
+
+	// ensure all expectations have been met
+	if err = mock.ExpectationsWereMet(); err != nil {
+		fmt.Printf("unmet expectation error: %s", err)
+	}
+	// Output:
+}
+
+func TestIssue14EscapeSQL(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+	mock.ExpectExec("INSERT INTO mytable\\(a, b\\)").
+		WithArgs("A", "B").
+		WillReturnResult(NewResult(1, 1))
+
+	_, err = db.Exec("INSERT INTO mytable(a, b) VALUES (?, ?)", "A", "B")
+	if err != nil {
+		t.Errorf("error '%s' was not expected, while inserting a row", err)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+// test the case when db is not triggered and expectations
+// are not asserted on close
+func TestIssue4(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectQuery("some sql query which will not be called").
+		WillReturnRows(NewRows([]string{"id"}))
+
+	if err := mock.ExpectationsWereMet(); err == nil {
+		t.Errorf("was expecting an error since query was not triggered")
+	}
+}
+
+func TestMockQuery(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
+
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
+		WithArgs(5).
+		WillReturnRows(rs)
+
+	rows, err := db.Query("SELECT (.+) FROM articles WHERE id = ?", 5)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
+	}
+
+	defer func() {
+		if er := rows.Close(); er != nil {
+			t.Error("Unexpected error while trying to close rows")
+		}
+	}()
+
+	if !rows.Next() {
+		t.Error("it must have had one row as result, but got empty result set instead")
+	}
+
+	var id int
+	var title string
+
+	err = rows.Scan(&id, &title)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while trying to scan row", err)
+	}
+
+	if id != 5 {
+		t.Errorf("expected mocked id to be 5, but got %d instead", id)
+	}
+
+	if title != "hello world" {
+		t.Errorf("expected mocked title to be 'hello world', but got '%s' instead", title)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestMockQueryTypes(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	columns := []string{"id", "timestamp", "sold"}
+
+	timestamp := time.Now()
+	rs := NewRows(columns)
+	rs.AddRow(5, timestamp, true)
+
+	mock.ExpectQuery("SELECT (.+) FROM sales WHERE id = ?").
+		WithArgs(5).
+		WillReturnRows(rs)
+
+	rows, err := db.Query("SELECT (.+) FROM sales WHERE id = ?", 5)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
+	}
+	defer func() {
+		if er := rows.Close(); er != nil {
+			t.Error("Unexpected error while trying to close rows")
+		}
+	}()
+	if !rows.Next() {
+		t.Error("it must have had one row as result, but got empty result set instead")
+	}
+
+	var id int
+	var time time.Time
+	var sold bool
+
+	err = rows.Scan(&id, &time, &sold)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while trying to scan row", err)
+	}
+
+	if id != 5 {
+		t.Errorf("expected mocked id to be 5, but got %d instead", id)
+	}
+
+	if time != timestamp {
+		t.Errorf("expected mocked time to be %s, but got '%s' instead", timestamp, time)
+	}
+
+	if sold != true {
+		t.Errorf("expected mocked boolean to be true, but got %v instead", sold)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestTransactionExpectations(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	// begin and commit
+	mock.ExpectBegin()
+	mock.ExpectCommit()
+
+	tx, err := db.Begin()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when beginning a transaction", err)
+	}
+
+	err = tx.Commit()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when committing a transaction", err)
+	}
+
+	// begin and rollback
+	mock.ExpectBegin()
+	mock.ExpectRollback()
+
+	tx, err = db.Begin()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when beginning a transaction", err)
+	}
+
+	err = tx.Rollback()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when rolling back a transaction", err)
+	}
+
+	// begin with an error
+	mock.ExpectBegin().WillReturnError(fmt.Errorf("some err"))
+
+	tx, err = db.Begin()
+	if err == nil {
+		t.Error("an error was expected when beginning a transaction, but got none")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestPrepareExpectations(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?")
+
+	stmt, err := db.Prepare("SELECT (.+) FROM articles WHERE id = ?")
+	if err != nil {
+		t.Errorf("error '%s' was not expected while creating a prepared statement", err)
+	}
+	if stmt == nil {
+		t.Errorf("stmt was expected while creating a prepared statement")
+	}
+
+	// expect something else, w/o ExpectPrepare()
+	var id int
+	var title string
+	rs := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
+
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
+		WithArgs(5).
+		WillReturnRows(rs)
+
+	err = stmt.QueryRow(5).Scan(&id, &title)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
+	}
+
+	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?").
+		WillReturnError(fmt.Errorf("Some DB error occurred"))
+
+	stmt, err = db.Prepare("SELECT id FROM articles WHERE id = ?")
+	if err == nil {
+		t.Error("error was expected while creating a prepared statement")
+	}
+	if stmt != nil {
+		t.Errorf("stmt was not expected while creating a prepared statement returning error")
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestPreparedQueryExecutions(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?")
+
+	rs1 := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
+		WithArgs(5).
+		WillReturnRows(rs1)
+
+	rs2 := NewRows([]string{"id", "title"}).FromCSVString("2,whoop")
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
+		WithArgs(2).
+		WillReturnRows(rs2)
+
+	stmt, err := db.Prepare("SELECT id, title FROM articles WHERE id = ?")
+	if err != nil {
+		t.Errorf("error '%s' was not expected while creating a prepared statement", err)
+	}
+
+	var id int
+	var title string
+	err = stmt.QueryRow(5).Scan(&id, &title)
+	if err != nil {
+		t.Errorf("error '%s' was not expected querying row from statement and scanning", err)
+	}
+
+	if id != 5 {
+		t.Errorf("expected mocked id to be 5, but got %d instead", id)
+	}
+
+	if title != "hello world" {
+		t.Errorf("expected mocked title to be 'hello world', but got '%s' instead", title)
+	}
+
+	err = stmt.QueryRow(2).Scan(&id, &title)
+	if err != nil {
+		t.Errorf("error '%s' was not expected querying row from statement and scanning", err)
+	}
+
+	if id != 2 {
+		t.Errorf("expected mocked id to be 2, but got %d instead", id)
+	}
+
+	if title != "whoop" {
+		t.Errorf("expected mocked title to be 'whoop', but got '%s' instead", title)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestUnexpectedOperations(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectPrepare("SELECT (.+) FROM articles WHERE id = ?")
+	stmt, err := db.Prepare("SELECT id, title FROM articles WHERE id = ?")
+	if err != nil {
+		t.Errorf("error '%s' was not expected while creating a prepared statement", err)
+	}
+
+	var id int
+	var title string
+
+	err = stmt.QueryRow(5).Scan(&id, &title)
+	if err == nil {
+		t.Error("error was expected querying row, since there was no such expectation")
+	}
+
+	mock.ExpectRollback()
+
+	if err := mock.ExpectationsWereMet(); err == nil {
+		t.Errorf("was expecting an error since query was not triggered")
+	}
+}
+
+func TestWrongExpectations(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectBegin()
+
+	rs1 := NewRows([]string{"id", "title"}).FromCSVString("5,hello world")
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
+		WithArgs(5).
+		WillReturnRows(rs1)
+
+	mock.ExpectCommit().WillReturnError(fmt.Errorf("deadlock occurred"))
+	mock.ExpectRollback() // won't be triggered
+
+	var id int
+	var title string
+
+	err = db.QueryRow("SELECT id, title FROM articles WHERE id = ? FOR UPDATE", 5).Scan(&id, &title)
+	if err == nil {
+		t.Error("error was expected while querying row, since there begin transaction expectation is not fulfilled")
+	}
+
+	// lets go around and start transaction
+	tx, err := db.Begin()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when beginning a transaction", err)
+	}
+
+	err = db.QueryRow("SELECT id, title FROM articles WHERE id = ? FOR UPDATE", 5).Scan(&id, &title)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while querying row, since transaction was started", err)
+	}
+
+	err = tx.Commit()
+	if err == nil {
+		t.Error("a deadlock error was expected when committing a transaction", err)
+	}
+
+	if err := mock.ExpectationsWereMet(); err == nil {
+		t.Errorf("was expecting an error since query was not triggered")
+	}
+}
+
+func TestExecExpectations(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	result := NewResult(1, 1)
+	mock.ExpectExec("^INSERT INTO articles").
+		WithArgs("hello").
+		WillReturnResult(result)
+
+	res, err := db.Exec("INSERT INTO articles (title) VALUES (?)", "hello")
+	if err != nil {
+		t.Errorf("error '%s' was not expected, while inserting a row", err)
+	}
+
+	id, err := res.LastInsertId()
+	if err != nil {
+		t.Errorf("error '%s' was not expected, while getting a last insert id", err)
+	}
+
+	affected, err := res.RowsAffected()
+	if err != nil {
+		t.Errorf("error '%s' was not expected, while getting affected rows", err)
+	}
+
+	if id != 1 {
+		t.Errorf("expected last insert id to be 1, but got %d instead", id)
+	}
+
+	if affected != 1 {
+		t.Errorf("expected affected rows to be 1, but got %d instead", affected)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestRowBuilderAndNilTypes(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs := NewRows([]string{"id", "active", "created", "status"}).
+		AddRow(1, true, time.Now(), 5).
+		AddRow(2, false, nil, nil)
+
+	mock.ExpectQuery("SELECT (.+) FROM sales").WillReturnRows(rs)
+
+	rows, err := db.Query("SELECT * FROM sales")
+	if err != nil {
+		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
+	}
+	defer func() {
+		if er := rows.Close(); er != nil {
+			t.Error("Unexpected error while trying to close rows")
+		}
+	}()
+
+	// NullTime and NullInt are used from stubs_test.go
+	var (
+		id      int
+		active  bool
+		created NullTime
+		status  NullInt
+	)
+
+	if !rows.Next() {
+		t.Error("it must have had row in rows, but got empty result set instead")
+	}
+
+	err = rows.Scan(&id, &active, &created, &status)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while trying to scan row", err)
+	}
+
+	if id != 1 {
+		t.Errorf("expected mocked id to be 1, but got %d instead", id)
+	}
+
+	if !active {
+		t.Errorf("expected 'active' to be 'true', but got '%v' instead", active)
+	}
+
+	if !created.Valid {
+		t.Errorf("expected 'created' to be valid, but it %+v is not", created)
+	}
+
+	if !status.Valid {
+		t.Errorf("expected 'status' to be valid, but it %+v is not", status)
+	}
+
+	if status.Integer != 5 {
+		t.Errorf("expected 'status' to be '5', but got '%d'", status.Integer)
+	}
+
+	// test second row
+	if !rows.Next() {
+		t.Error("it must have had row in rows, but got empty result set instead")
+	}
+
+	err = rows.Scan(&id, &active, &created, &status)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while trying to scan row", err)
+	}
+
+	if id != 2 {
+		t.Errorf("expected mocked id to be 2, but got %d instead", id)
+	}
+
+	if active {
+		t.Errorf("expected 'active' to be 'false', but got '%v' instead", active)
+	}
+
+	if created.Valid {
+		t.Errorf("expected 'created' to be invalid, but it %+v is not", created)
+	}
+
+	if status.Valid {
+		t.Errorf("expected 'status' to be invalid, but it %+v is not", status)
+	}
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestArgumentReflectValueTypeError(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs := NewRows([]string{"id"}).AddRow(1)
+
+	mock.ExpectQuery("SELECT (.+) FROM sales").WithArgs(5.5).WillReturnRows(rs)
+
+	_, err = db.Query("SELECT * FROM sales WHERE x = ?", 5)
+	if err == nil {
+		t.Error("Expected error, but got none")
+	}
+}
+
+func TestGoroutineExecutionWithUnorderedExpectationMatching(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	// note this line is important for unordered expectation matching
+	mock.MatchExpectationsInOrder(false)
+
+	result := NewResult(1, 1)
+
+	mock.ExpectExec("^UPDATE one").WithArgs("one").WillReturnResult(result)
+	mock.ExpectExec("^UPDATE two").WithArgs("one", "two").WillReturnResult(result)
+	mock.ExpectExec("^UPDATE three").WithArgs("one", "two", "three").WillReturnResult(result)
+
+	var wg sync.WaitGroup
+	queries := map[string][]interface{}{
+		"one":   []interface{}{"one"},
+		"two":   []interface{}{"one", "two"},
+		"three": []interface{}{"one", "two", "three"},
+	}
+
+	wg.Add(len(queries))
+	for table, args := range queries {
+		go func(tbl string, a []interface{}) {
+			if _, err := db.Exec("UPDATE "+tbl, a...); err != nil {
+				t.Errorf("error was not expected: %s", err)
+			}
+			wg.Done()
+		}(table, args)
+	}
+
+	wg.Wait()
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func ExampleSqlmock_goroutines() {
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("failed to open sqlmock database:", err)
+	}
+	defer db.Close()
+
+	// note this line is important for unordered expectation matching
+	mock.MatchExpectationsInOrder(false)
+
+	result := NewResult(1, 1)
+
+	mock.ExpectExec("^UPDATE one").WithArgs("one").WillReturnResult(result)
+	mock.ExpectExec("^UPDATE two").WithArgs("one", "two").WillReturnResult(result)
+	mock.ExpectExec("^UPDATE three").WithArgs("one", "two", "three").WillReturnResult(result)
+
+	var wg sync.WaitGroup
+	queries := map[string][]interface{}{
+		"one":   []interface{}{"one"},
+		"two":   []interface{}{"one", "two"},
+		"three": []interface{}{"one", "two", "three"},
+	}
+
+	wg.Add(len(queries))
+	for table, args := range queries {
+		go func(tbl string, a []interface{}) {
+			if _, err := db.Exec("UPDATE "+tbl, a...); err != nil {
+				fmt.Println("error was not expected:", err)
+			}
+			wg.Done()
+		}(table, args)
+	}
+
+	wg.Wait()
+
+	if err := mock.ExpectationsWereMet(); err != nil {
+		fmt.Println("there were unfulfilled expections:", err)
+	}
+	// Output:
+}
+
+// False Positive - passes despite mismatched Exec
+// see #37 issue
+func TestRunExecsWithOrderedShouldNotMeetAllExpectations(t *testing.T) {
+	db, dbmock, _ := New()
+	dbmock.ExpectExec("THE FIRST EXEC")
+	dbmock.ExpectExec("THE SECOND EXEC")
+
+	_, _ = db.Exec("THE FIRST EXEC")
+	_, _ = db.Exec("THE WRONG EXEC")
+
+	err := dbmock.ExpectationsWereMet()
+	if err == nil {
+		t.Fatal("was expecting an error, but there wasn't any")
+	}
+}
+
+// False Positive - passes despite mismatched Exec
+// see #37 issue
+func TestRunQueriesWithOrderedShouldNotMeetAllExpectations(t *testing.T) {
+	db, dbmock, _ := New()
+	dbmock.ExpectQuery("THE FIRST QUERY")
+	dbmock.ExpectQuery("THE SECOND QUERY")
+
+	_, _ = db.Query("THE FIRST QUERY")
+	_, _ = db.Query("THE WRONG QUERY")
+
+	err := dbmock.ExpectationsWereMet()
+	if err == nil {
+		t.Fatal("was expecting an error, but there wasn't any")
+	}
+}
+
+func TestRunExecsWithExpectedErrorMeetsExpectations(t *testing.T) {
+	db, dbmock, _ := New()
+	dbmock.ExpectExec("THE FIRST EXEC").WillReturnError(fmt.Errorf("big bad bug"))
+	dbmock.ExpectExec("THE SECOND EXEC").WillReturnResult(NewResult(0, 0))
+
+	_, _ = db.Exec("THE FIRST EXEC")
+	_, _ = db.Exec("THE SECOND EXEC")
+
+	err := dbmock.ExpectationsWereMet()
+	if err != nil {
+		t.Fatalf("all expectations should be met: %s", err)
+	}
+}
+
+func TestRunQueryWithExpectedErrorMeetsExpectations(t *testing.T) {
+	db, dbmock, _ := New()
+	dbmock.ExpectQuery("THE FIRST QUERY").WillReturnError(fmt.Errorf("big bad bug"))
+	dbmock.ExpectQuery("THE SECOND QUERY").WillReturnRows(NewRows([]string{"col"}).AddRow(1))
+
+	_, _ = db.Query("THE FIRST QUERY")
+	_, _ = db.Query("THE SECOND QUERY")
+
+	err := dbmock.ExpectationsWereMet()
+	if err != nil {
+		t.Fatalf("all expectations should be met: %s", err)
+	}
+}
+
+func TestEmptyRowSet(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	rs := NewRows([]string{"id", "title"})
+
+	mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
+		WithArgs(5).
+		WillReturnRows(rs)
+
+	rows, err := db.Query("SELECT (.+) FROM articles WHERE id = ?", 5)
+	if err != nil {
+		t.Errorf("error '%s' was not expected while retrieving mock rows", err)
+	}
+
+	defer func() {
+		if er := rows.Close(); er != nil {
+			t.Error("Unexpected error while trying to close rows")
+		}
+	}()
+
+	if rows.Next() {
+		t.Error("expected no rows but got one")
+	}
+
+	err = mock.ExpectationsWereMet()
+	if err != nil {
+		t.Fatalf("all expectations should be met: %s", err)
+	}
+}
+
+// Based on issue #50
+func TestPrepareExpectationNotFulfilled(t *testing.T) {
+	t.Parallel()
+	db, mock, err := New()
+	if err != nil {
+		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
+	}
+	defer db.Close()
+
+	mock.ExpectPrepare("^BADSELECT$")
+
+	if _, err := db.Prepare("SELECT"); err == nil {
+		t.Fatal("prepare should not match expected query string")
+	}
+
+	if err := mock.ExpectationsWereMet(); err == nil {
+		t.Errorf("was expecting an error, since prepared statement query does not match, but there was none")
+	}
+}
+
+func TestRollbackThrow(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	// columns to be used for result
+	columns := []string{"id", "status"}
+	// expect transaction begin
+	mock.ExpectBegin()
+	// expect query to fetch order, match it with regexp
+	mock.ExpectQuery("SELECT (.+) FROM orders (.+) FOR UPDATE").
+		WithArgs(1).
+		WillReturnRows(NewRows(columns).AddRow(1, 1))
+	// expect transaction rollback, since order status is "cancelled"
+	mock.ExpectRollback().WillReturnError(fmt.Errorf("rollback failed"))
+
+	// run the cancel order function
+	someOrderID := 1
+	// call a function which executes expected database operations
+	err = cancelOrder(db, someOrderID)
+	if err == nil {
+		t.Error("an error was expected when rolling back transaction, but got none")
+	}
+
+	// ensure all expectations have been met
+	if err = mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("unmet expectation error: %s", err)
+	}
+	// Output:
+}
+
+func TestUnexpectedCommit(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	mock.ExpectBegin()
+	tx, _ := db.Begin()
+	if err := tx.Commit(); err == nil {
+		t.Error("an error was expected when calling commit, but got none")
+	}
+}
+
+func TestUnexpectedCommitOrder(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	mock.ExpectBegin()
+	mock.ExpectRollback().WillReturnError(fmt.Errorf("Rollback failed"))
+	tx, _ := db.Begin()
+	if err := tx.Commit(); err == nil {
+		t.Error("an error was expected when calling commit, but got none")
+	}
+}
+
+func TestExpectedCommitOrder(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	mock.ExpectCommit().WillReturnError(fmt.Errorf("Commit failed"))
+	if _, err := db.Begin(); err == nil {
+		t.Error("an error was expected when calling begin, but got none")
+	}
+}
+
+func TestUnexpectedRollback(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	mock.ExpectBegin()
+	tx, _ := db.Begin()
+	if err := tx.Rollback(); err == nil {
+		t.Error("an error was expected when calling rollback, but got none")
+	}
+}
+
+func TestUnexpectedRollbackOrder(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	mock.ExpectBegin()
+
+	tx, _ := db.Begin()
+	if err := tx.Rollback(); err == nil {
+		t.Error("an error was expected when calling rollback, but got none")
+	}
+}
+
+func TestPrepareExec(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	defer db.Close()
+	mock.ExpectBegin()
+	ep := mock.ExpectPrepare("INSERT INTO ORDERS\\(ID, STATUS\\) VALUES \\(\\?, \\?\\)")
+	for i := 0; i < 3; i++ {
+		ep.ExpectExec().WillReturnResult(NewResult(1, 1))
+	}
+	mock.ExpectCommit()
+	tx, _ := db.Begin()
+	stmt, err := tx.Prepare("INSERT INTO ORDERS(ID, STATUS) VALUES (?, ?)")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer stmt.Close()
+	for i := 0; i < 3; i++ {
+		_, err := stmt.Exec(i, "Hello"+strconv.Itoa(i))
+		if err != nil {
+			t.Fatal(err)
+		}
+	}
+	tx.Commit()
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestPrepareQuery(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	defer db.Close()
+	mock.ExpectBegin()
+	ep := mock.ExpectPrepare("SELECT ID, STATUS FROM ORDERS WHERE ID = \\?")
+	ep.ExpectQuery().WithArgs(101).WillReturnRows(NewRows([]string{"ID", "STATUS"}).AddRow(101, "Hello"))
+	mock.ExpectCommit()
+	tx, _ := db.Begin()
+	stmt, err := tx.Prepare("SELECT ID, STATUS FROM ORDERS WHERE ID = ?")
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer stmt.Close()
+	rows, err := stmt.Query(101)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer rows.Close()
+	for rows.Next() {
+		var (
+			id     int
+			status string
+		)
+		if rows.Scan(&id, &status); id != 101 || status != "Hello" {
+			t.Fatal("wrong query results")
+		}
+
+	}
+	tx.Commit()
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestExpectedCloseError(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	mock.ExpectClose().WillReturnError(fmt.Errorf("Close failed"))
+	if err := db.Close(); err == nil {
+		t.Error("an error was expected when calling close, but got none")
+	}
+	if err := mock.ExpectationsWereMet(); err != nil {
+		t.Errorf("there were unfulfilled expections: %s", err)
+	}
+}
+
+func TestExpectedCloseOrder(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	defer db.Close()
+	mock.ExpectClose().WillReturnError(fmt.Errorf("Close failed"))
+	db.Begin()
+	if err := mock.ExpectationsWereMet(); err == nil {
+		t.Error("expected error on ExpectationsWereMet")
+	}
+}
+
+func TestExpectedBeginOrder(t *testing.T) {
+	// Open new mock database
+	db, mock, err := New()
+	if err != nil {
+		fmt.Println("error creating mock database")
+		return
+	}
+	mock.ExpectBegin().WillReturnError(fmt.Errorf("Begin failed"))
+	if err := db.Close(); err == nil {
+		t.Error("an error was expected when calling close, but got none")
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement.go
new file mode 100644
index 0000000..df73740
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement.go
@@ -0,0 +1,27 @@
+package sqlmock
+
+import (
+	"database/sql/driver"
+)
+
+type statement struct {
+	conn  *sqlmock
+	query string
+	err   error
+}
+
+func (stmt *statement) Close() error {
+	return stmt.err
+}
+
+func (stmt *statement) NumInput() int {
+	return -1
+}
+
+func (stmt *statement) Exec(args []driver.Value) (driver.Result, error) {
+	return stmt.conn.Exec(stmt.query, args)
+}
+
+func (stmt *statement) Query(args []driver.Value) (driver.Rows, error) {
+	return stmt.conn.Query(stmt.query, args)
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement_test.go
new file mode 100644
index 0000000..f951f63
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/statement_test.go
@@ -0,0 +1,33 @@
+// +build go1.6
+
+package sqlmock
+
+import (
+	"errors"
+	"testing"
+)
+
+func TestExpectedPreparedStatemtCloseError(t *testing.T) {
+	conn, mock, err := New()
+	if err != nil {
+		t.Fatal("failed to open sqlmock database:", err)
+	}
+
+	mock.ExpectBegin()
+	want := errors.New("STMT ERROR")
+	mock.ExpectPrepare("SELECT").WillReturnCloseError(want)
+
+	txn, err := conn.Begin()
+	if err != nil {
+		t.Fatal("unexpected error while opening transaction:", err)
+	}
+
+	stmt, err := txn.Prepare("SELECT")
+	if err != nil {
+		t.Fatal("unexpected error while preparing a statement:", err)
+	}
+
+	if err := stmt.Close(); err != want {
+		t.Fatalf("Got = %v, want = %v", err, want)
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/stubs_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/stubs_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/stubs_test.go
new file mode 100644
index 0000000..d3c6003
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/stubs_test.go
@@ -0,0 +1,76 @@
+package sqlmock
+
+import (
+	"database/sql/driver"
+	"fmt"
+	"strconv"
+	"time"
+)
+
+type NullTime struct {
+	Time  time.Time
+	Valid bool // Valid is true if Time is not NULL
+}
+
+type NullInt struct {
+	Integer int
+	Valid   bool
+}
+
+// Satisfy sql.Scanner interface
+func (ni *NullInt) Scan(value interface{}) (err error) {
+	if value == nil {
+		ni.Integer, ni.Valid = 0, false
+		return
+	}
+
+	switch v := value.(type) {
+	case int, int8, int16, int32, int64:
+		ni.Integer, ni.Valid = v.(int), true
+		return
+	case []byte:
+		ni.Integer, err = strconv.Atoi(string(v))
+		ni.Valid = (err == nil)
+		return
+	case string:
+		ni.Integer, err = strconv.Atoi(v)
+		ni.Valid = (err == nil)
+		return
+	}
+
+	ni.Valid = false
+	return fmt.Errorf("Can't convert %T to integer", value)
+}
+
+// Satisfy sql.Valuer interface.
+func (ni NullInt) Value() (driver.Value, error) {
+	if !ni.Valid {
+		return nil, nil
+	}
+	return ni.Integer, nil
+}
+
+// Satisfy sql.Scanner interface
+func (nt *NullTime) Scan(value interface{}) (err error) {
+	if value == nil {
+		nt.Time, nt.Valid = time.Time{}, false
+		return
+	}
+
+	switch v := value.(type) {
+	case time.Time:
+		nt.Time, nt.Valid = v, true
+		return
+	}
+
+	nt.Valid = false
+	return fmt.Errorf("Can't convert %T to time.Time", value)
+}
+
+// Satisfy sql.Valuer interface.
+func (nt NullTime) Value() (driver.Value, error) {
+	if !nt.Valid {
+		return nil, nil
+	}
+	return nt.Time, nil
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util.go
new file mode 100644
index 0000000..072e380
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util.go
@@ -0,0 +1,13 @@
+package sqlmock
+
+import (
+	"regexp"
+	"strings"
+)
+
+var re = regexp.MustCompile("\\s+")
+
+// strip out new lines and trim spaces
+func stripQuery(q string) (s string) {
+	return strings.TrimSpace(re.ReplaceAllString(q, " "))
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util_test.go
new file mode 100644
index 0000000..c4b3974
--- /dev/null
+++ b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock.v1/util_test.go
@@ -0,0 +1,21 @@
+package sqlmock
+
+import (
+	"testing"
+)
+
+func TestQueryStringStripping(t *testing.T) {
+	assert := func(actual, expected string) {
+		if res := stripQuery(actual); res != expected {
+			t.Errorf("Expected '%s' to be '%s', but got '%s'", actual, expected, res)
+		}
+	}
+
+	assert(" SELECT 1", "SELECT 1")
+	assert("SELECT   1 FROM   d", "SELECT 1 FROM d")
+	assert(`
+    SELECT c
+    FROM D
+`, "SELECT c FROM D")
+	assert("UPDATE  (.+) SET  ", "UPDATE (.+) SET")
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/LICENSE
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/LICENSE b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/LICENSE
deleted file mode 100644
index 7f8bedf..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/LICENSE
+++ /dev/null
@@ -1,28 +0,0 @@
-The three clause BSD license (http://en.wikipedia.org/wiki/BSD_licenses)
-
-Copyright (c) 2013-2017, DATA-DOG team
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this
-  list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright notice,
-  this list of conditions and the following disclaimer in the documentation
-  and/or other materials provided with the distribution.
-
-* The name DataDog.lt may not be used to endorse or promote products
-  derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/README.md
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/README.md b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/README.md
deleted file mode 100644
index f3d5487..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/README.md
+++ /dev/null
@@ -1,223 +0,0 @@
-[![Build Status](https://travis-ci.org/DATA-DOG/go-sqlmock.png)](https://travis-ci.org/DATA-DOG/go-sqlmock)
-[![GoDoc](https://godoc.org/github.com/DATA-DOG/go-sqlmock?status.png)](https://godoc.org/github.com/DATA-DOG/go-sqlmock)
-[![codecov.io](https://codecov.io/github/DATA-DOG/go-sqlmock/branch/master/graph/badge.svg)](https://codecov.io/github/DATA-DOG/go-sqlmock)
-
-# Sql driver mock for Golang
-
-**sqlmock** is a mock library implementing [sql/driver](https://godoc.org/database/sql/driver). Which has one and only
-purpose - to simulate any **sql** driver behavior in tests, without needing a real database connection. It helps to
-maintain correct **TDD** workflow.
-
-- this library is now complete and stable. (you may not find new changes for this reason)
-- supports concurrency and multiple connections.
-- supports **go1.8** Context related feature mocking and Named sql parameters.
-- does not require any modifications to your source code.
-- the driver allows to mock any sql driver method behavior.
-- has strict by default expectation order matching.
-- has no third party dependencies.
-
-## Install
-
-    go get gopkg.in/DATA-DOG/go-sqlmock.v1
-
-## Documentation and Examples
-
-Visit [godoc](http://godoc.org/github.com/DATA-DOG/go-sqlmock) for general examples and public api reference.
-See **.travis.yml** for supported **go** versions.
-Different use case, is to functionally test with a real database - [go-txdb](https://github.com/DATA-DOG/go-txdb)
-all database related actions are isolated within a single transaction so the database can remain in the same state.
-
-See implementation examples:
-
-- [blog API server](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/blog)
-- [the same orders example](https://github.com/DATA-DOG/go-sqlmock/tree/master/examples/orders)
-
-### Something you may want to test
-
-``` go
-package main
-
-import "database/sql"
-
-func recordStats(db *sql.DB, userID, productID int64) (err error) {
-	tx, err := db.Begin()
-	if err != nil {
-		return
-	}
-
-	defer func() {
-		switch err {
-		case nil:
-			err = tx.Commit()
-		default:
-			tx.Rollback()
-		}
-	}()
-
-	if _, err = tx.Exec("UPDATE products SET views = views + 1"); err != nil {
-		return
-	}
-	if _, err = tx.Exec("INSERT INTO product_viewers (user_id, product_id) VALUES (?, ?)", userID, productID); err != nil {
-		return
-	}
-	return
-}
-
-func main() {
-	// @NOTE: the real connection is not required for tests
-	db, err := sql.Open("mysql", "root@/blog")
-	if err != nil {
-		panic(err)
-	}
-	defer db.Close()
-
-	if err = recordStats(db, 1 /*some user id*/, 5 /*some product id*/); err != nil {
-		panic(err)
-	}
-}
-```
-
-### Tests with sqlmock
-
-``` go
-package main
-
-import (
-	"fmt"
-	"testing"
-
-	"gopkg.in/DATA-DOG/go-sqlmock.v1"
-)
-
-// a successful case
-func TestShouldUpdateStats(t *testing.T) {
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectBegin()
-	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
-	mock.ExpectExec("INSERT INTO product_viewers").WithArgs(2, 3).WillReturnResult(sqlmock.NewResult(1, 1))
-	mock.ExpectCommit()
-
-	// now we execute our method
-	if err = recordStats(db, 2, 3); err != nil {
-		t.Errorf("error was not expected while updating stats: %s", err)
-	}
-
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-// a failing test case
-func TestShouldRollbackStatUpdatesOnFailure(t *testing.T) {
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectBegin()
-	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
-	mock.ExpectExec("INSERT INTO product_viewers").
-		WithArgs(2, 3).
-		WillReturnError(fmt.Errorf("some error"))
-	mock.ExpectRollback()
-
-	// now we execute our method
-	if err = recordStats(db, 2, 3); err == nil {
-		t.Errorf("was expecting an error, but there was none")
-	}
-
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-```
-
-## Matching arguments like time.Time
-
-There may be arguments which are of `struct` type and cannot be compared easily by value like `time.Time`. In this case
-**sqlmock** provides an [Argument](https://godoc.org/github.com/DATA-DOG/go-sqlmock#Argument) interface which
-can be used in more sophisticated matching. Here is a simple example of time argument matching:
-
-``` go
-type AnyTime struct{}
-
-// Match satisfies sqlmock.Argument interface
-func (a AnyTime) Match(v driver.Value) bool {
-	_, ok := v.(time.Time)
-	return ok
-}
-
-func TestAnyTimeArgument(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectExec("INSERT INTO users").
-		WithArgs("john", AnyTime{}).
-		WillReturnResult(NewResult(1, 1))
-
-	_, err = db.Exec("INSERT INTO users(name, created_at) VALUES (?, ?)", "john", time.Now())
-	if err != nil {
-		t.Errorf("error '%s' was not expected, while inserting a row", err)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-```
-
-It only asserts that argument is of `time.Time` type.
-
-## Run tests
-
-    go test -race
-
-## Change Log
-
-- **2017-02-09** - implemented support for **go1.8** features. **Rows** interface was changed to struct
-  but contains all methods as before and should maintain backwards compatibility. **ExpectedQuery.WillReturnRows** may now
-  accept multiple row sets.
-- **2016-11-02** - `db.Prepare()` was not validating expected prepare SQL
-  query. It should still be validated even if Exec or Query is not
-  executed on that prepared statement.
-- **2016-02-23** - added **sqlmock.AnyArg()** function to provide any kind
-  of argument matcher.
-- **2016-02-23** - convert expected arguments to driver.Value as natural
-  driver does, the change may affect time.Time comparison and will be
-  stricter. See [issue](https://github.com/DATA-DOG/go-sqlmock/issues/31).
-- **2015-08-27** - **v1** api change, concurrency support, all known issues fixed.
-- **2014-08-16** instead of **panic** during reflect type mismatch when comparing query arguments - now return error
-- **2014-08-14** added **sqlmock.NewErrorResult** which gives an option to return driver.Result with errors for
-interface methods, see [issue](https://github.com/DATA-DOG/go-sqlmock/issues/5)
-- **2014-05-29** allow to match arguments in more sophisticated ways, by providing an **sqlmock.Argument** interface
-- **2014-04-21** introduce **sqlmock.New()** to open a mock database connection for tests. This method
-calls sql.DB.Ping to ensure that connection is open, see [issue](https://github.com/DATA-DOG/go-sqlmock/issues/4).
-This way on Close it will surely assert if all expectations are met, even if database was not triggered at all.
-The old way is still available, but it is advisable to call db.Ping manually before asserting with db.Close.
-- **2014-02-14** RowsFromCSVString is now a part of Rows interface named as FromCSVString.
-It has changed to allow more ways to construct rows and to easily extend this API in future.
-See [issue 1](https://github.com/DATA-DOG/go-sqlmock/issues/1)
-**RowsFromCSVString** is deprecated and will be removed in future
-
-## Contributions
-
-Feel free to open a pull request. Note, if you wish to contribute an extension to public (exported methods or types) -
-please open an issue before, to discuss whether these changes can be accepted. All backward incompatible changes are
-and will be treated cautiously
-
-## License
-
-The [three clause BSD license](http://en.wikipedia.org/wiki/BSD_licenses)
-

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument.go
deleted file mode 100644
index 7727481..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package sqlmock
-
-import "database/sql/driver"
-
-// Argument interface allows to match
-// any argument in specific way when used with
-// ExpectedQuery and ExpectedExec expectations.
-type Argument interface {
-	Match(driver.Value) bool
-}
-
-// AnyArg will return an Argument which can
-// match any kind of arguments.
-//
-// Useful for time.Time or similar kinds of arguments.
-func AnyArg() Argument {
-	return anyArgument{}
-}
-
-type anyArgument struct{}
-
-func (a anyArgument) Match(_ driver.Value) bool {
-	return true
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument_test.go
deleted file mode 100644
index 3088ed4..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/argument_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql/driver"
-	"testing"
-	"time"
-)
-
-type AnyTime struct{}
-
-// Match satisfies sqlmock.Argument interface
-func (a AnyTime) Match(v driver.Value) bool {
-	_, ok := v.(time.Time)
-	return ok
-}
-
-func TestAnyTimeArgument(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectExec("INSERT INTO users").
-		WithArgs("john", AnyTime{}).
-		WillReturnResult(NewResult(1, 1))
-
-	_, err = db.Exec("INSERT INTO users(name, created_at) VALUES (?, ?)", "john", time.Now())
-	if err != nil {
-		t.Errorf("error '%s' was not expected, while inserting a row", err)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestByteSliceArgument(t *testing.T) {
-	t.Parallel()
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	username := []byte("user")
-	mock.ExpectExec("INSERT INTO users").WithArgs(username).WillReturnResult(NewResult(1, 1))
-
-	_, err = db.Exec("INSERT INTO users(username) VALUES (?)", username)
-	if err != nil {
-		t.Errorf("error '%s' was not expected, while inserting a row", err)
-	}
-
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver.go
deleted file mode 100644
index 2a480fe..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql"
-	"database/sql/driver"
-	"fmt"
-	"sync"
-)
-
-var pool *mockDriver
-
-func init() {
-	pool = &mockDriver{
-		conns: make(map[string]*sqlmock),
-	}
-	sql.Register("sqlmock", pool)
-}
-
-type mockDriver struct {
-	sync.Mutex
-	counter int
-	conns   map[string]*sqlmock
-}
-
-func (d *mockDriver) Open(dsn string) (driver.Conn, error) {
-	d.Lock()
-	defer d.Unlock()
-
-	c, ok := d.conns[dsn]
-	if !ok {
-		return c, fmt.Errorf("expected a connection to be available, but it is not")
-	}
-
-	c.opened++
-	return c, nil
-}
-
-// New creates sqlmock database connection
-// and a mock to manage expectations.
-// Pings db so that all expectations could be
-// asserted.
-func New() (*sql.DB, Sqlmock, error) {
-	pool.Lock()
-	dsn := fmt.Sprintf("sqlmock_db_%d", pool.counter)
-	pool.counter++
-
-	smock := &sqlmock{dsn: dsn, drv: pool, ordered: true}
-	pool.conns[dsn] = smock
-	pool.Unlock()
-
-	return smock.open()
-}
-
-// NewWithDSN creates sqlmock database connection
-// with a specific DSN and a mock to manage expectations.
-// Pings db so that all expectations could be asserted.
-//
-// This method is introduced because of sql abstraction
-// libraries, which do not provide a way to initialize
-// with sql.DB instance. For example GORM library.
-//
-// Note, it will error if attempted to create with an
-// already used dsn
-//
-// It is not recommended to use this method, unless you
-// really need it and there is no other way around.
-func NewWithDSN(dsn string) (*sql.DB, Sqlmock, error) {
-	pool.Lock()
-	if _, ok := pool.conns[dsn]; ok {
-		pool.Unlock()
-		return nil, nil, fmt.Errorf("cannot create a new mock database with the same dsn: %s", dsn)
-	}
-	smock := &sqlmock{dsn: dsn, drv: pool, ordered: true}
-	pool.conns[dsn] = smock
-	pool.Unlock()
-
-	return smock.open()
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver_test.go
deleted file mode 100644
index 1a65c1c..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/driver_test.go
+++ /dev/null
@@ -1,112 +0,0 @@
-package sqlmock
-
-import (
-	"fmt"
-	"testing"
-)
-
-type void struct{}
-
-func (void) Print(...interface{}) {}
-
-func ExampleNew() {
-	db, mock, err := New()
-	if err != nil {
-		fmt.Println("expected no error, but got:", err)
-		return
-	}
-	defer db.Close()
-	// now we can expect operations performed on db
-	mock.ExpectBegin().WillReturnError(fmt.Errorf("an error will occur on db.Begin() call"))
-}
-
-func TestShouldOpenConnectionIssue15(t *testing.T) {
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("expected no error, but got: %s", err)
-	}
-	if len(pool.conns) != 1 {
-		t.Errorf("expected 1 connection in pool, but there is: %d", len(pool.conns))
-	}
-
-	smock, _ := mock.(*sqlmock)
-	if smock.opened != 1 {
-		t.Errorf("expected 1 connection on mock to be opened, but there is: %d", smock.opened)
-	}
-
-	// defer so the rows gets closed first
-	defer func() {
-		if smock.opened != 0 {
-			t.Errorf("expected no connections on mock to be opened, but there is: %d", smock.opened)
-		}
-	}()
-
-	mock.ExpectQuery("SELECT").WillReturnRows(NewRows([]string{"one", "two"}).AddRow("val1", "val2"))
-	rows, err := db.Query("SELECT")
-	if err != nil {
-		t.Errorf("unexpected error: %s", err)
-	}
-	defer rows.Close()
-
-	mock.ExpectExec("UPDATE").WillReturnResult(NewResult(1, 1))
-	if _, err = db.Exec("UPDATE"); err != nil {
-		t.Errorf("unexpected error: %s", err)
-	}
-
-	// now there should be two connections open
-	if smock.opened != 2 {
-		t.Errorf("expected 2 connection on mock to be opened, but there is: %d", smock.opened)
-	}
-
-	mock.ExpectClose()
-	if err = db.Close(); err != nil {
-		t.Errorf("expected no error on close, but got: %s", err)
-	}
-
-	// one is still reserved for rows
-	if smock.opened != 1 {
-		t.Errorf("expected 1 connection on mock to be still reserved for rows, but there is: %d", smock.opened)
-	}
-}
-
-func TestTwoOpenConnectionsOnTheSameDSN(t *testing.T) {
-	db, mock, err := New()
-	if err != nil {
-		t.Errorf("expected no error, but got: %s", err)
-	}
-	db2, mock2, err := New()
-	if err != nil {
-		t.Errorf("expected no error, but got: %s", err)
-	}
-	if len(pool.conns) != 2 {
-		t.Errorf("expected 2 connection in pool, but there is: %d", len(pool.conns))
-	}
-
-	if db == db2 {
-		t.Errorf("expected not the same database instance, but it is the same")
-	}
-	if mock == mock2 {
-		t.Errorf("expected not the same mock instance, but it is the same")
-	}
-}
-
-func TestWrongDSN(t *testing.T) {
-	t.Parallel()
-	db, _, _ := New()
-	defer db.Close()
-	if _, err := db.Driver().Open("wrong_dsn"); err == nil {
-		t.Error("expected error on Open")
-	}
-}
-
-func TestNewDSN(t *testing.T) {
-	if _, _, err := NewWithDSN("sqlmock_db_99"); err != nil {
-		t.Errorf("expected no error on NewWithDSN, but got: %s", err)
-	}
-}
-
-func TestDuplicateNewDSN(t *testing.T) {
-	if _, _, err := NewWithDSN("sqlmock_db_1"); err == nil {
-		t.Error("expected error on NewWithDSN")
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic.go
deleted file mode 100644
index 0fbf98d..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package main
-
-import "database/sql"
-
-func recordStats(db *sql.DB, userID, productID int64) (err error) {
-	tx, err := db.Begin()
-	if err != nil {
-		return
-	}
-
-	defer func() {
-		switch err {
-		case nil:
-			err = tx.Commit()
-		default:
-			tx.Rollback()
-		}
-	}()
-
-	if _, err = tx.Exec("UPDATE products SET views = views + 1"); err != nil {
-		return
-	}
-	if _, err = tx.Exec("INSERT INTO product_viewers (user_id, product_id) VALUES (?, ?)", userID, productID); err != nil {
-		return
-	}
-	return
-}
-
-func main() {
-	// @NOTE: the real connection is not required for tests
-	db, err := sql.Open("mysql", "root@/blog")
-	if err != nil {
-		panic(err)
-	}
-	defer db.Close()
-
-	if err = recordStats(db, 1 /*some user id*/, 5 /*some product id*/); err != nil {
-		panic(err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic_test.go
deleted file mode 100644
index 0825f90..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/basic/basic_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"testing"
-
-	"github.com/DATA-DOG/go-sqlmock"
-)
-
-// a successful case
-func TestShouldUpdateStats(t *testing.T) {
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectBegin()
-	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
-	mock.ExpectExec("INSERT INTO product_viewers").WithArgs(2, 3).WillReturnResult(sqlmock.NewResult(1, 1))
-	mock.ExpectCommit()
-
-	// now we execute our method
-	if err = recordStats(db, 2, 3); err != nil {
-		t.Errorf("error was not expected while updating stats: %s", err)
-	}
-
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-// a failing test case
-func TestShouldRollbackStatUpdatesOnFailure(t *testing.T) {
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	mock.ExpectBegin()
-	mock.ExpectExec("UPDATE products").WillReturnResult(sqlmock.NewResult(1, 1))
-	mock.ExpectExec("INSERT INTO product_viewers").
-		WithArgs(2, 3).
-		WillReturnError(fmt.Errorf("some error"))
-	mock.ExpectRollback()
-
-	// now we execute our method
-	if err = recordStats(db, 2, 3); err == nil {
-		t.Errorf("was expecting an error, but there was none")
-	}
-
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog.go
deleted file mode 100644
index c4aec06..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package main
-
-import (
-	"database/sql"
-	"encoding/json"
-	"net/http"
-)
-
-type api struct {
-	db *sql.DB
-}
-
-type post struct {
-	ID    int
-	Title string
-	Body  string
-}
-
-func (a *api) posts(w http.ResponseWriter, r *http.Request) {
-	rows, err := a.db.Query("SELECT id, title, body FROM posts")
-	if err != nil {
-		a.fail(w, "failed to fetch posts: "+err.Error(), 500)
-		return
-	}
-	defer rows.Close()
-
-	var posts []*post
-	for rows.Next() {
-		p := &post{}
-		if err := rows.Scan(&p.ID, &p.Title, &p.Body); err != nil {
-			a.fail(w, "failed to scan post: "+err.Error(), 500)
-			return
-		}
-		posts = append(posts, p)
-	}
-	if rows.Err() != nil {
-		a.fail(w, "failed to read all posts: "+rows.Err().Error(), 500)
-		return
-	}
-
-	data := struct {
-		Posts []*post
-	}{posts}
-
-	a.ok(w, data)
-}
-
-func main() {
-	// @NOTE: the real connection is not required for tests
-	db, err := sql.Open("mysql", "root@/blog")
-	if err != nil {
-		panic(err)
-	}
-	app := &api{db: db}
-	http.HandleFunc("/posts", app.posts)
-	http.ListenAndServe(":8080", nil)
-}
-
-func (a *api) fail(w http.ResponseWriter, msg string, status int) {
-	w.Header().Set("Content-Type", "application/json")
-
-	data := struct {
-		Error string
-	}{Error: msg}
-
-	resp, _ := json.Marshal(data)
-	w.WriteHeader(status)
-	w.Write(resp)
-}
-
-func (a *api) ok(w http.ResponseWriter, data interface{}) {
-	w.Header().Set("Content-Type", "application/json")
-
-	resp, err := json.Marshal(data)
-	if err != nil {
-		w.WriteHeader(http.StatusInternalServerError)
-		a.fail(w, "oops something evil has happened", 500)
-		return
-	}
-	w.Write(resp)
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog_test.go
deleted file mode 100644
index aa1881a..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/blog/blog_test.go
+++ /dev/null
@@ -1,102 +0,0 @@
-package main
-
-import (
-	"bytes"
-	"encoding/json"
-	"fmt"
-	"net/http"
-	"net/http/httptest"
-	"testing"
-
-	"github.com/DATA-DOG/go-sqlmock"
-)
-
-func (a *api) assertJSON(actual []byte, data interface{}, t *testing.T) {
-	expected, err := json.Marshal(data)
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when marshaling expected json data", err)
-	}
-
-	if bytes.Compare(expected, actual) != 0 {
-		t.Errorf("the expected json: %s is different from actual %s", expected, actual)
-	}
-}
-
-func TestShouldGetPosts(t *testing.T) {
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	// create app with mocked db, request and response to test
-	app := &api{db}
-	req, err := http.NewRequest("GET", "http://localhost/posts", nil)
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected while creating request", err)
-	}
-	w := httptest.NewRecorder()
-
-	// before we actually execute our api function, we need to expect required DB actions
-	rows := sqlmock.NewRows([]string{"id", "title", "body"}).
-		AddRow(1, "post 1", "hello").
-		AddRow(2, "post 2", "world")
-
-	mock.ExpectQuery("^SELECT (.+) FROM posts$").WillReturnRows(rows)
-
-	// now we execute our request
-	app.posts(w, req)
-
-	if w.Code != 200 {
-		t.Fatalf("expected status code to be 200, but got: %d", w.Code)
-	}
-
-	data := struct {
-		Posts []*post
-	}{Posts: []*post{
-		{ID: 1, Title: "post 1", Body: "hello"},
-		{ID: 2, Title: "post 2", Body: "world"},
-	}}
-	app.assertJSON(w.Body.Bytes(), data, t)
-
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-func TestShouldRespondWithErrorOnFailure(t *testing.T) {
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	// create app with mocked db, request and response to test
-	app := &api{db}
-	req, err := http.NewRequest("GET", "http://localhost/posts", nil)
-	if err != nil {
-		t.Fatalf("an error '%s' was not expected while creating request", err)
-	}
-	w := httptest.NewRecorder()
-
-	// before we actually execute our api function, we need to expect required DB actions
-	mock.ExpectQuery("^SELECT (.+) FROM posts$").WillReturnError(fmt.Errorf("some error"))
-
-	// now we execute our request
-	app.posts(w, req)
-
-	if w.Code != 500 {
-		t.Fatalf("expected status code to be 500, but got: %d", w.Code)
-	}
-
-	data := struct {
-		Error string
-	}{"failed to fetch posts: some error"}
-	app.assertJSON(w.Body.Bytes(), data, t)
-
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/doc.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/doc.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/doc.go
deleted file mode 100644
index c7842af..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/doc.go
+++ /dev/null
@@ -1 +0,0 @@
-package examples

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders.go
deleted file mode 100644
index fb7e47e..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders.go
+++ /dev/null
@@ -1,121 +0,0 @@
-package main
-
-import (
-	"database/sql"
-	"fmt"
-	"log"
-
-	"github.com/kisielk/sqlstruct"
-)
-
-const ORDER_PENDING = 0
-const ORDER_CANCELLED = 1
-
-type User struct {
-	Id       int     `sql:"id"`
-	Username string  `sql:"username"`
-	Balance  float64 `sql:"balance"`
-}
-
-type Order struct {
-	Id          int     `sql:"id"`
-	Value       float64 `sql:"value"`
-	ReservedFee float64 `sql:"reserved_fee"`
-	Status      int     `sql:"status"`
-}
-
-func cancelOrder(id int, db *sql.DB) (err error) {
-	tx, err := db.Begin()
-	if err != nil {
-		return
-	}
-
-	var order Order
-	var user User
-	sql := fmt.Sprintf(`
-SELECT %s, %s
-FROM orders AS o
-INNER JOIN users AS u ON o.buyer_id = u.id
-WHERE o.id = ?
-FOR UPDATE`,
-		sqlstruct.ColumnsAliased(order, "o"),
-		sqlstruct.ColumnsAliased(user, "u"))
-
-	// fetch order to cancel
-	rows, err := tx.Query(sql, id)
-	if err != nil {
-		tx.Rollback()
-		return
-	}
-
-	defer rows.Close()
-	// no rows, nothing to do
-	if !rows.Next() {
-		tx.Rollback()
-		return
-	}
-
-	// read order
-	err = sqlstruct.ScanAliased(&order, rows, "o")
-	if err != nil {
-		tx.Rollback()
-		return
-	}
-
-	// ensure order status
-	if order.Status != ORDER_PENDING {
-		tx.Rollback()
-		return
-	}
-
-	// read user
-	err = sqlstruct.ScanAliased(&user, rows, "u")
-	if err != nil {
-		tx.Rollback()
-		return
-	}
-	rows.Close() // manually close before other prepared statements
-
-	// refund order value
-	sql = "UPDATE users SET balance = balance + ? WHERE id = ?"
-	refundStmt, err := tx.Prepare(sql)
-	if err != nil {
-		tx.Rollback()
-		return
-	}
-	defer refundStmt.Close()
-	_, err = refundStmt.Exec(order.Value+order.ReservedFee, user.Id)
-	if err != nil {
-		tx.Rollback()
-		return
-	}
-
-	// update order status
-	order.Status = ORDER_CANCELLED
-	sql = "UPDATE orders SET status = ?, updated = NOW() WHERE id = ?"
-	orderUpdStmt, err := tx.Prepare(sql)
-	if err != nil {
-		tx.Rollback()
-		return
-	}
-	defer orderUpdStmt.Close()
-	_, err = orderUpdStmt.Exec(order.Status, order.Id)
-	if err != nil {
-		tx.Rollback()
-		return
-	}
-	return tx.Commit()
-}
-
-func main() {
-	// @NOTE: the real connection is not required for tests
-	db, err := sql.Open("mysql", "root:@/orders")
-	if err != nil {
-		log.Fatal(err)
-	}
-	defer db.Close()
-	err = cancelOrder(1, db)
-	if err != nil {
-		log.Fatal(err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders_test.go
deleted file mode 100644
index 7562b8f..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/examples/orders/orders_test.go
+++ /dev/null
@@ -1,108 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"testing"
-
-	"github.com/DATA-DOG/go-sqlmock"
-)
-
-// will test that order with a different status, cannot be cancelled
-func TestShouldNotCancelOrderWithNonPendingStatus(t *testing.T) {
-	// open database stub
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Errorf("An error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	// columns are prefixed with "o" since we used sqlstruct to generate them
-	columns := []string{"o_id", "o_status"}
-	// expect transaction begin
-	mock.ExpectBegin()
-	// expect query to fetch order and user, match it with regexp
-	mock.ExpectQuery("SELECT (.+) FROM orders AS o INNER JOIN users AS u (.+) FOR UPDATE").
-		WithArgs(1).
-		WillReturnRows(sqlmock.NewRows(columns).FromCSVString("1,1"))
-	// expect transaction rollback, since order status is "cancelled"
-	mock.ExpectRollback()
-
-	// run the cancel order function
-	err = cancelOrder(1, db)
-	if err != nil {
-		t.Errorf("Expected no error, but got %s instead", err)
-	}
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-// will test order cancellation
-func TestShouldRefundUserWhenOrderIsCancelled(t *testing.T) {
-	// open database stub
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Errorf("An error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	// columns are prefixed with "o" since we used sqlstruct to generate them
-	columns := []string{"o_id", "o_status", "o_value", "o_reserved_fee", "u_id", "u_balance"}
-	// expect transaction begin
-	mock.ExpectBegin()
-	// expect query to fetch order and user, match it with regexp
-	mock.ExpectQuery("SELECT (.+) FROM orders AS o INNER JOIN users AS u (.+) FOR UPDATE").
-		WithArgs(1).
-		WillReturnRows(sqlmock.NewRows(columns).AddRow(1, 0, 25.75, 3.25, 2, 10.00))
-	// expect user balance update
-	mock.ExpectPrepare("UPDATE users SET balance").ExpectExec().
-		WithArgs(25.75+3.25, 2).                  // refund amount, user id
-		WillReturnResult(sqlmock.NewResult(0, 1)) // no insert id, 1 affected row
-	// expect order status update
-	mock.ExpectPrepare("UPDATE orders SET status").ExpectExec().
-		WithArgs(ORDER_CANCELLED, 1).             // status, id
-		WillReturnResult(sqlmock.NewResult(0, 1)) // no insert id, 1 affected row
-	// expect a transaction commit
-	mock.ExpectCommit()
-
-	// run the cancel order function
-	err = cancelOrder(1, db)
-	if err != nil {
-		t.Errorf("Expected no error, but got %s instead", err)
-	}
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}
-
-// will test order cancellation
-func TestShouldRollbackOnError(t *testing.T) {
-	// open database stub
-	db, mock, err := sqlmock.New()
-	if err != nil {
-		t.Errorf("An error '%s' was not expected when opening a stub database connection", err)
-	}
-	defer db.Close()
-
-	// expect transaction begin
-	mock.ExpectBegin()
-	// expect query to fetch order and user, match it with regexp
-	mock.ExpectQuery("SELECT (.+) FROM orders AS o INNER JOIN users AS u (.+) FOR UPDATE").
-		WithArgs(1).
-		WillReturnError(fmt.Errorf("Some error"))
-	// should rollback since error was returned from query execution
-	mock.ExpectRollback()
-
-	// run the cancel order function
-	err = cancelOrder(1, db)
-	// error should return back
-	if err == nil {
-		t.Error("Expected error, but got none")
-	}
-	// we make sure that all expectations were met
-	if err := mock.ExpectationsWereMet(); err != nil {
-		t.Errorf("there were unfulfilled expections: %s", err)
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations.go
deleted file mode 100644
index 415759e..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations.go
+++ /dev/null
@@ -1,344 +0,0 @@
-package sqlmock
-
-import (
-	"database/sql/driver"
-	"fmt"
-	"regexp"
-	"strings"
-	"sync"
-	"time"
-)
-
-// an expectation interface
-type expectation interface {
-	fulfilled() bool
-	Lock()
-	Unlock()
-	String() string
-}
-
-// common expectation struct
-// satisfies the expectation interface
-type commonExpectation struct {
-	sync.Mutex
-	triggered bool
-	err       error
-}
-
-func (e *commonExpectation) fulfilled() bool {
-	return e.triggered
-}
-
-// ExpectedClose is used to manage *sql.DB.Close expectation
-// returned by *Sqlmock.ExpectClose.
-type ExpectedClose struct {
-	commonExpectation
-}
-
-// WillReturnError allows to set an error for *sql.DB.Close action
-func (e *ExpectedClose) WillReturnError(err error) *ExpectedClose {
-	e.err = err
-	return e
-}
-
-// String returns string representation
-func (e *ExpectedClose) String() string {
-	msg := "ExpectedClose => expecting database Close"
-	if e.err != nil {
-		msg += fmt.Sprintf(", which should return error: %s", e.err)
-	}
-	return msg
-}
-
-// ExpectedBegin is used to manage *sql.DB.Begin expectation
-// returned by *Sqlmock.ExpectBegin.
-type ExpectedBegin struct {
-	commonExpectation
-	delay time.Duration
-}
-
-// WillReturnError allows to set an error for *sql.DB.Begin action
-func (e *ExpectedBegin) WillReturnError(err error) *ExpectedBegin {
-	e.err = err
-	return e
-}
-
-// String returns string representation
-func (e *ExpectedBegin) String() string {
-	msg := "ExpectedBegin => expecting database transaction Begin"
-	if e.err != nil {
-		msg += fmt.Sprintf(", which should return error: %s", e.err)
-	}
-	return msg
-}
-
-// WillDelayFor allows to specify duration for which it will delay
-// result. May be used together with Context
-func (e *ExpectedBegin) WillDelayFor(duration time.Duration) *ExpectedBegin {
-	e.delay = duration
-	return e
-}
-
-// ExpectedCommit is used to manage *sql.Tx.Commit expectation
-// returned by *Sqlmock.ExpectCommit.
-type ExpectedCommit struct {
-	commonExpectation
-}
-
-// WillReturnError allows to set an error for *sql.Tx.Close action
-func (e *ExpectedCommit) WillReturnError(err error) *ExpectedCommit {
-	e.err = err
-	return e
-}
-
-// String returns string representation
-func (e *ExpectedCommit) String() string {
-	msg := "ExpectedCommit => expecting transaction Commit"
-	if e.err != nil {
-		msg += fmt.Sprintf(", which should return error: %s", e.err)
-	}
-	return msg
-}
-
-// ExpectedRollback is used to manage *sql.Tx.Rollback expectation
-// returned by *Sqlmock.ExpectRollback.
-type ExpectedRollback struct {
-	commonExpectation
-}
-
-// WillReturnError allows to set an error for *sql.Tx.Rollback action
-func (e *ExpectedRollback) WillReturnError(err error) *ExpectedRollback {
-	e.err = err
-	return e
-}
-
-// String returns string representation
-func (e *ExpectedRollback) String() string {
-	msg := "ExpectedRollback => expecting transaction Rollback"
-	if e.err != nil {
-		msg += fmt.Sprintf(", which should return error: %s", e.err)
-	}
-	return msg
-}
-
-// ExpectedQuery is used to manage *sql.DB.Query, *dql.DB.QueryRow, *sql.Tx.Query,
-// *sql.Tx.QueryRow, *sql.Stmt.Query or *sql.Stmt.QueryRow expectations.
-// Returned by *Sqlmock.ExpectQuery.
-type ExpectedQuery struct {
-	queryBasedExpectation
-	rows  driver.Rows
-	delay time.Duration
-}
-
-// WithArgs will match given expected args to actual database query arguments.
-// if at least one argument does not match, it will return an error. For specific
-// arguments an sqlmock.Argument interface can be used to match an argument.
-func (e *ExpectedQuery) WithArgs(args ...driver.Value) *ExpectedQuery {
-	e.args = args
-	return e
-}
-
-// WillReturnError allows to set an error for expected database query
-func (e *ExpectedQuery) WillReturnError(err error) *ExpectedQuery {
-	e.err = err
-	return e
-}
-
-// WillDelayFor allows to specify duration for which it will delay
-// result. May be used together with Context
-func (e *ExpectedQuery) WillDelayFor(duration time.Duration) *ExpectedQuery {
-	e.delay = duration
-	return e
-}
-
-// String returns string representation
-func (e *ExpectedQuery) String() string {
-	msg := "ExpectedQuery => expecting Query or QueryRow which:"
-	msg += "\n  - matches sql: '" + e.sqlRegex.String() + "'"
-
-	if len(e.args) == 0 {
-		msg += "\n  - is without arguments"
-	} else {
-		msg += "\n  - is with arguments:\n"
-		for i, arg := range e.args {
-			msg += fmt.Sprintf("    %d - %+v\n", i, arg)
-		}
-		msg = strings.TrimSpace(msg)
-	}
-
-	if e.rows != nil {
-		msg += fmt.Sprintf("\n  - %s", e.rows)
-	}
-
-	if e.err != nil {
-		msg += fmt.Sprintf("\n  - should return error: %s", e.err)
-	}
-
-	return msg
-}
-
-// ExpectedExec is used to manage *sql.DB.Exec, *sql.Tx.Exec or *sql.Stmt.Exec expectations.
-// Returned by *Sqlmock.ExpectExec.
-type ExpectedExec struct {
-	queryBasedExpectation
-	result driver.Result
-	delay  time.Duration
-}
-
-// WithArgs will match given expected args to actual database exec operation arguments.
-// if at least one argument does not match, it will return an error. For specific
-// arguments an sqlmock.Argument interface can be used to match an argument.
-func (e *ExpectedExec) WithArgs(args ...driver.Value) *ExpectedExec {
-	e.args = args
-	return e
-}
-
-// WillReturnError allows to set an error for expected database exec action
-func (e *ExpectedExec) WillReturnError(err error) *ExpectedExec {
-	e.err = err
-	return e
-}
-
-// WillDelayFor allows to specify duration for which it will delay
-// result. May be used together with Context
-func (e *ExpectedExec) WillDelayFor(duration time.Duration) *ExpectedExec {
-	e.delay = duration
-	return e
-}
-
-// String returns string representation
-func (e *ExpectedExec) String() string {
-	msg := "ExpectedExec => expecting Exec which:"
-	msg += "\n  - matches sql: '" + e.sqlRegex.String() + "'"
-
-	if len(e.args) == 0 {
-		msg += "\n  - is without arguments"
-	} else {
-		msg += "\n  - is with arguments:\n"
-		var margs []string
-		for i, arg := range e.args {
-			margs = append(margs, fmt.Sprintf("    %d - %+v", i, arg))
-		}
-		msg += strings.Join(margs, "\n")
-	}
-
-	if e.result != nil {
-		res, _ := e.result.(*result)
-		msg += "\n  - should return Result having:"
-		msg += fmt.Sprintf("\n      LastInsertId: %d", res.insertID)
-		msg += fmt.Sprintf("\n      RowsAffected: %d", res.rowsAffected)
-		if res.err != nil {
-			msg += fmt.Sprintf("\n      Error: %s", res.err)
-		}
-	}
-
-	if e.err != nil {
-		msg += fmt.Sprintf("\n  - should return error: %s", e.err)
-	}
-
-	return msg
-}
-
-// WillReturnResult arranges for an expected Exec() to return a particular
-// result, there is sqlmock.NewResult(lastInsertID int64, affectedRows int64) method
-// to build a corresponding result. Or if actions needs to be tested against errors
-// sqlmock.NewErrorResult(err error) to return a given error.
-func (e *ExpectedExec) WillReturnResult(result driver.Result) *ExpectedExec {
-	e.result = result
-	return e
-}
-
-// ExpectedPrepare is used to manage *sql.DB.Prepare or *sql.Tx.Prepare expectations.
-// Returned by *Sqlmock.ExpectPrepare.
-type ExpectedPrepare struct {
-	commonExpectation
-	mock      *sqlmock
-	sqlRegex  *regexp.Regexp
-	statement driver.Stmt
-	closeErr  error
-	delay     time.Duration
-}
-
-// WillReturnError allows to set an error for the expected *sql.DB.Prepare or *sql.Tx.Prepare action.
-func (e *ExpectedPrepare) WillReturnError(err error) *ExpectedPrepare {
-	e.err = err
-	return e
-}
-
-// WillReturnCloseError allows to set an error for this prapared statement Close action
-func (e *ExpectedPrepare) WillReturnCloseError(err error) *ExpectedPrepare {
-	e.closeErr = err
-	return e
-}
-
-// WillDelayFor allows to specify duration for which it will delay
-// result. May be used together with Context
-func (e *ExpectedPrepare) WillDelayFor(duration time.Duration) *ExpectedPrepare {
-	e.delay = duration
-	return e
-}
-
-// ExpectQuery allows to expect Query() or QueryRow() on this prepared statement.
-// this method is convenient in order to prevent duplicating sql query string matching.
-func (e *ExpectedPrepare) ExpectQuery() *ExpectedQuery {
-	eq := &ExpectedQuery{}
-	eq.sqlRegex = e.sqlRegex
-	e.mock.expected = append(e.mock.expected, eq)
-	return eq
-}
-
-// ExpectExec allows to expect Exec() on this prepared statement.
-// this method is convenient in order to prevent duplicating sql query string matching.
-func (e *ExpectedPrepare) ExpectExec() *ExpectedExec {
-	eq := &ExpectedExec{}
-	eq.sqlRegex = e.sqlRegex
-	e.mock.expected = append(e.mock.expected, eq)
-	return eq
-}
-
-// String returns string representation
-func (e *ExpectedPrepare) String() string {
-	msg := "ExpectedPrepare => expecting Prepare statement which:"
-	msg += "\n  - matches sql: '" + e.sqlRegex.String() + "'"
-
-	if e.err != nil {
-		msg += fmt.Sprintf("\n  - should return error: %s", e.err)
-	}
-
-	if e.closeErr != nil {
-		msg += fmt.Sprintf("\n  - should return error on Close: %s", e.closeErr)
-	}
-
-	return msg
-}
-
-// query based expectation
-// adds a query matching logic
-type queryBasedExpectation struct {
-	commonExpectation
-	sqlRegex *regexp.Regexp
-	args     []driver.Value
-}
-
-func (e *queryBasedExpectation) attemptMatch(sql string, args []namedValue) (err error) {
-	if !e.queryMatches(sql) {
-		return fmt.Errorf(`could not match sql: "%s" with expected regexp "%s"`, sql, e.sqlRegex.String())
-	}
-
-	// catch panic
-	defer func() {
-		if e := recover(); e != nil {
-			_, ok := e.(error)
-			if !ok {
-				err = fmt.Errorf(e.(string))
-			}
-		}
-	}()
-
-	err = e.argsMatches(args)
-	return
-}
-
-func (e *queryBasedExpectation) queryMatches(sql string) bool {
-	return e.sqlRegex.MatchString(sql)
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_before_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_before_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_before_go18.go
deleted file mode 100644
index 146f240..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_before_go18.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// +build !go1.8
-
-package sqlmock
-
-import (
-	"database/sql/driver"
-	"fmt"
-	"reflect"
-)
-
-// WillReturnRows specifies the set of resulting rows that will be returned
-// by the triggered query
-func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery {
-	e.rows = &rowSets{sets: []*Rows{rows}}
-	return e
-}
-
-func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
-	if nil == e.args {
-		return nil
-	}
-	if len(args) != len(e.args) {
-		return fmt.Errorf("expected %d, but got %d arguments", len(e.args), len(args))
-	}
-	for k, v := range args {
-		// custom argument matcher
-		matcher, ok := e.args[k].(Argument)
-		if ok {
-			// @TODO: does it make sense to pass value instead of named value?
-			if !matcher.Match(v.Value) {
-				return fmt.Errorf("matcher %T could not match %d argument %T - %+v", matcher, k, args[k], args[k])
-			}
-			continue
-		}
-
-		dval := e.args[k]
-		// convert to driver converter
-		darg, err := driver.DefaultParameterConverter.ConvertValue(dval)
-		if err != nil {
-			return fmt.Errorf("could not convert %d argument %T - %+v to driver value: %s", k, e.args[k], e.args[k], err)
-		}
-
-		if !driver.IsValue(darg) {
-			return fmt.Errorf("argument %d: non-subset type %T returned from Value", k, darg)
-		}
-
-		if !reflect.DeepEqual(darg, v.Value) {
-			return fmt.Errorf("argument %d expected [%T - %+v] does not match actual [%T - %+v]", k, darg, darg, v.Value, v.Value)
-		}
-	}
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18.go
deleted file mode 100644
index 2b4b44e..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// +build go1.8
-
-package sqlmock
-
-import (
-	"database/sql"
-	"database/sql/driver"
-	"fmt"
-	"reflect"
-)
-
-// WillReturnRows specifies the set of resulting rows that will be returned
-// by the triggered query
-func (e *ExpectedQuery) WillReturnRows(rows ...*Rows) *ExpectedQuery {
-	sets := make([]*Rows, len(rows))
-	for i, r := range rows {
-		sets[i] = r
-	}
-	e.rows = &rowSets{sets: sets}
-	return e
-}
-
-func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
-	if nil == e.args {
-		return nil
-	}
-	if len(args) != len(e.args) {
-		return fmt.Errorf("expected %d, but got %d arguments", len(e.args), len(args))
-	}
-	// @TODO should we assert either all args are named or ordinal?
-	for k, v := range args {
-		// custom argument matcher
-		matcher, ok := e.args[k].(Argument)
-		if ok {
-			if !matcher.Match(v.Value) {
-				return fmt.Errorf("matcher %T could not match %d argument %T - %+v", matcher, k, args[k], args[k])
-			}
-			continue
-		}
-
-		dval := e.args[k]
-		if named, isNamed := dval.(sql.NamedArg); isNamed {
-			dval = named.Value
-			if v.Name != named.Name {
-				return fmt.Errorf("named argument %d: name: \"%s\" does not match expected: \"%s\"", k, v.Name, named.Name)
-			}
-		} else if k+1 != v.Ordinal {
-			return fmt.Errorf("argument %d: ordinal position: %d does not match expected: %d", k, k+1, v.Ordinal)
-		}
-
-		// convert to driver converter
-		darg, err := driver.DefaultParameterConverter.ConvertValue(dval)
-		if err != nil {
-			return fmt.Errorf("could not convert %d argument %T - %+v to driver value: %s", k, e.args[k], e.args[k], err)
-		}
-
-		if !driver.IsValue(darg) {
-			return fmt.Errorf("argument %d: non-subset type %T returned from Value", k, darg)
-		}
-
-		if !reflect.DeepEqual(darg, v.Value) {
-			return fmt.Errorf("argument %d expected [%T - %+v] does not match actual [%T - %+v]", k, darg, darg, v.Value, v.Value)
-		}
-	}
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/13fd7151/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18_test.go b/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18_test.go
deleted file mode 100644
index 5f30d2f..0000000
--- a/traffic_ops/traffic_ops_golang/vendor/gopkg.in/DATA-DOG/go-sqlmock/expectations_go18_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// +build go1.8
-
-package sqlmock
-
-import (
-	"database/sql"
-	"database/sql/driver"
-	"testing"
-)
-
-func TestQueryExpectationNamedArgComparison(t *testing.T) {
-	e := &queryBasedExpectation{}
-	against := []namedValue{{Value: int64(5), Name: "id"}}
-	if err := e.argsMatches(against); err != nil {
-		t.Errorf("arguments should match, since the no expectation was set, but got err: %s", err)
-	}
-
-	e.args = []driver.Value{
-		sql.Named("id", 5),
-		sql.Named("s", "str"),
-	}
-
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments should not match, since the size is not the same")
-	}
-
-	against = []namedValue{
-		{Value: int64(5), Name: "id"},
-		{Value: "str", Name: "s"},
-	}
-
-	if err := e.argsMatches(against); err != nil {
-		t.Errorf("arguments should have matched, but it did not: %v", err)
-	}
-
-	against = []namedValue{
-		{Value: int64(5), Name: "id"},
-		{Value: "str", Name: "username"},
-	}
-
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments matched, but it should have not due to Name")
-	}
-
-	e.args = []driver.Value{int64(5), "str"}
-
-	against = []namedValue{
-		{Value: int64(5), Ordinal: 0},
-		{Value: "str", Ordinal: 1},
-	}
-
-	if err := e.argsMatches(against); err == nil {
-		t.Error("arguments matched, but it should have not due to wrong Ordinal position")
-	}
-
-	against = []namedValue{
-		{Value: int64(5), Ordinal: 1},
-		{Value: "str", Ordinal: 2},
-	}
-
-	if err := e.argsMatches(against); err != nil {
-		t.Errorf("arguments should have matched, but it did not: %v", err)
-	}
-}