Fix #418 Added MySQL as DB storage layer. (#575)

* Fix #418 Added MySQL as DB storage layer.

* Make the mysql stuff work

* Make the mysql stuff work

* Make the mysql stuff work

* Make the mysql stuff work

* small fixes

* Switch to Go 1.8 installation inside CI (#589)

* Switch to Go 1.8 installation inside CI

Partially Addresses: #588

* Use url.Hostname() instead of custom method

* Added PR review changes.

* Added missing check for error.

* Changed * with name, config

* Removed unused import.

* Added check for NoRows

* Merged changes with HEAD

* Added documentation to mysql.go

* update mysql to be on par with postgres
This commit is contained in:
Martin Pinto-Bazurco Mendieta
2017-03-21 20:01:17 +01:00
committed by Seif Lotfy سيف لطفي
parent 353a144081
commit e4b3105d92
6 changed files with 757 additions and 17 deletions

View File

@@ -8,12 +8,13 @@ import (
"github.com/iron-io/functions/api/models"
"net/http"
"net/url"
"os"
"reflect"
"github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
"reflect"
"net/http"
"os"
"net/url"
)
func setLogBuffer() *bytes.Buffer {
@@ -73,12 +74,12 @@ func Test(t *testing.T, ds models.Datastore) {
{
// Set a config var
updated, err := ds.UpdateApp(ctx,
&models.App{Name: testApp.Name, Config: map[string]string{"TEST":"1"}})
&models.App{Name: testApp.Name, Config: map[string]string{"TEST": "1"}})
if err != nil {
t.Log(buf.String())
t.Fatalf("Test UpdateApp: error when updating app: %v", err)
}
expected := &models.App{Name: testApp.Name, Config: map[string]string{"TEST":"1"}}
expected := &models.App{Name: testApp.Name, Config: map[string]string{"TEST": "1"}}
if !reflect.DeepEqual(*updated, *expected) {
t.Log(buf.String())
t.Fatalf("Test UpdateApp: expected updated `%v` but got `%v`", expected, updated)
@@ -86,12 +87,12 @@ func Test(t *testing.T, ds models.Datastore) {
// Set a different var (without clearing the existing)
updated, err = ds.UpdateApp(ctx,
&models.App{Name: testApp.Name, Config: map[string]string{"OTHER":"TEST"}})
&models.App{Name: testApp.Name, Config: map[string]string{"OTHER": "TEST"}})
if err != nil {
t.Log(buf.String())
t.Fatalf("Test UpdateApp: error when updating app: %v", err)
}
expected = &models.App{Name: testApp.Name, Config: map[string]string{"TEST":"1","OTHER":"TEST"}}
expected = &models.App{Name: testApp.Name, Config: map[string]string{"TEST": "1", "OTHER": "TEST"}}
if !reflect.DeepEqual(*updated, *expected) {
t.Log(buf.String())
t.Fatalf("Test UpdateApp: expected updated `%v` but got `%v`", expected, updated)
@@ -99,12 +100,12 @@ func Test(t *testing.T, ds models.Datastore) {
// Delete a var
updated, err = ds.UpdateApp(ctx,
&models.App{Name: testApp.Name, Config: map[string]string{"TEST":""}})
&models.App{Name: testApp.Name, Config: map[string]string{"TEST": ""}})
if err != nil {
t.Log(buf.String())
t.Fatalf("Test UpdateApp: error when updating app: %v", err)
}
expected = &models.App{Name: testApp.Name, Config: map[string]string{"OTHER":"TEST"}}
expected = &models.App{Name: testApp.Name, Config: map[string]string{"OTHER": "TEST"}}
if !reflect.DeepEqual(*updated, *expected) {
t.Log(buf.String())
t.Fatalf("Test UpdateApp: expected updated `%v` but got `%v`", expected, updated)
@@ -247,7 +248,6 @@ func Test(t *testing.T, ds models.Datastore) {
}
}
// Testing update
{
// Update some fields, and add 3 configs and 3 headers.
@@ -485,4 +485,4 @@ var testRoute = &models.Route{
Image: "iron/hello",
Type: "sync",
Format: "http",
}
}