小编Tan*_*per的帖子

Jasmine使用templateUrl测试AngularJS指令

我正在使用Jasmine为AngularJS编写指令测试,并使用templateUrl:https://gist.github.com/tanepiper/62bd10125e8408def5cc

但是,当我运行测试时,我得到了gist中包含的错误:

Error: Unexpected request: GET views/currency-select.html
Run Code Online (Sandbox Code Playgroud)

从我在文档中看到的,我认为我正确地做了这个,但它似乎不是这样 - 我在这里错过了什么?

谢谢

unit-testing jasmine angularjs angularjs-directive

70
推荐指数
4
解决办法
4万
查看次数

Go和Gin:传递struct的数据库上下文?

我刚刚开始尝试Go,我正在寻找重新实现用它编写的节点中的API服务器.

尝试使用依赖注入来传递数据库上下文作为杜松子酒中间件,我遇到了障碍.到目前为止,我已将其设置为:

main.go:

package main

import (
        "fmt"
        "runtime"
        "log"
        "github.com/gin-gonic/gin"
        "votesforschools.com/api/public"
        "votesforschools.com/api/models"
)

type DB struct {
        models.DataStore
}

func main() {
        ConfigRuntime()
        ConfigServer()
}

func Database(connectionString string) gin.HandlerFunc {
        dbInstance, err := models.NewDB(connectionString)
        if err != nil {
                log.Panic(err)
        }

        db := &DB{dbInstance}

        return func(c *gin.Context) {
                c.Set("DB", db)
                c.Next()
        }
}


func ConfigRuntime() {
        nuCPU := runtime.NumCPU()
        runtime.GOMAXPROCS(nuCPU)
        fmt.Printf("Running with %d CPUs\n", nuCPU)
}

func ConfigServer() {

        gin.SetMode(gin.ReleaseMode)

        router := gin.New()
        router.Use(Database("<connectionstring>"))
        router.GET("/public/current-vote-pack", public.GetCurrentVotePack)
        router.Run(":1000")
}
Run Code Online (Sandbox Code Playgroud)

车型/ …

dependency-injection go go-gin

8
推荐指数
2
解决办法
5917
查看次数