db

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvKeyJobName = "JOB_NAME"
	EnvKeyPodName = "POD_NAME"
)
View Source
const (
	// Job is the `job` Endpoint map key
	Job = "job"
	// JobUpdate is the `job` PUT Endpoint map key
	JobUpdate = "jobUpdate"
	// Statistic is the `result` Endpoint map key
	Statistic = "statistic"
	// Timing is the `timing` Endpoint map key
	Timing = "timing"
	// Status is the `status` Endpoint map key
	Status = "status"
)

Variables

View Source
var Endpoints = map[string]string{
	Job:       "/job",
	JobUpdate: "/job/:id",
	Statistic: "/result",
	Timing:    "/timing",
	Status:    "/status",
}

Examples of endpoints for accessing the test results DB

View Source
var HTTPClient *http.Client

HTTPClient is the http.Client to use for all REST API requests

Functions

func GuardProduction

func GuardProduction(t *testing.T)

GuardProduction will cause a test to fail if the URL looks like a production URL. Use this as the first line in a Test to prevent accidentally saving library tests results in production DB.

Types

type Db

type Db struct {
	GcpProjectID string
}

Represents a DB client

func New

func New(gcpProjectID string) *Db

Creates a new DB client to access the DB

func (*Db) Save

func (g *Db) Save(jobID int, stats []constants.Statistics) (IDs []int, err error)

Writes a set of data.Statistics to the DB database and returns the row numbers

func (*Db) SaveJobStart

func (g *Db) SaveJobStart() (int, error)

Writes the initial job record to DB and returns the row ID This marks the start of a test run

type MySQLTime

type MySQLTime struct {
	time.Time
}

MySQLTime is a wrapper on time.Time that will marshall to MySQL timestamp format for Json

func (MySQLTime) MarshalJSON

func (t MySQLTime) MarshalJSON() ([]byte, error)

type ServerResponse

type ServerResponse struct {
	ID     int    `json:"id"`
	Status string `json:"status"`
	Error  string `json:"error"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL