All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.golang.database.executor.service_executor.test.go.template Maven / Gradle / Ivy

package executor_test

import (
	"context"
	"database/sql"
	"errors"
	"testing"

	fs @go_proto_path@
	"@code_url@@namespace@/@service_name@/zerotouch/golang/database/executor"
	"@code_url@@namespace@/@service_name@/zerotouch/golang/database/mappers"
	"github.com/DATA-DOG/go-sqlmock"
	entsql "github.com/facebook/ent/dialect/sql"
	"github.com/stretchr/testify/assert"
	"github.com/spf13/viper"
	"fmt"
	"go.uber.org/zap"
)

var Mock sqlmock.Sqlmock

func init() {
	var db *sql.DB
	var err error
	db, Mock, err = sqlmock.New()
	if err != nil {
		panic(err)
	}
	executor.Driver.Driver = entsql.OpenDB("mysql", db)
	viper.SetConfigType("json")
    viper.SetConfigFile("../../../../config" + "/config.json")
    viper.AutomaticEnv()
    if err := viper.ReadInConfig(); err != nil {
        fmt.Println("VIPER config read error",zap.Error(err))
    }
}

@insert_test_functions@




© 2015 - 2024 Weber Informatics LLC | Privacy Policy