草庐IT

test-git-flow

全部标签

git - Gig2go : unpacking the sent packfile failed on the remote

我为此苦苦挣扎。我正在尝试使用以下代码将更改推送到存储库://Getremoteremote,err:=repo.Remotes.Lookup("origin")iferr!=nil{remote,err=repo.Remotes.Create("origin",repo.Path())iferr!=nil{returnerr}}//Getthebranchbranch,err:=repo.Branch()iferr!=nil{returnerr}//GetthenamebranchName,err:=branch.Name()iferr!=nil{returnerr}iferr:=r

testing - 带 channel 的 Golang 测试不退出

下面的Golang测试永远不会退出。我怀疑这与channel死锁有关,但作为一个菜鸟,我不太确定。constuserName="xxxxxxxxxxxx"funcTestSynchroninze(t*testing.T){c,err:=channel.New(github.ChannelName,authToken)iferr!=nil{t.Fatalf("Couldnotcreatechannel:%s",err)return}state:=channel.NewState(nil)ctx:=context.Background()ctx=context.WithValue(ctx,

testing - Golang NewRequest 将 POST 参数传递给 API 进行测试

这是我的测试方法,它创建一个新请求并传递POST参数。url1:="/api/addprospect"data:=url.Values{}data.Add("customer_name","value")b:=bytes.NewBuffer([]byte(data.Encode()))request,err:=http.NewRequest("POST",serverHttp.URL+url1,b)res,err:=http.DefaultClient.Do(request)问题是POSTparam没有被url的函数处理程序获取。你能帮我设置正确的请求吗?谢谢

testing - 针对 xml/字符串测试失败的自定义 testify 输出

我正在使用testify测试XML编码(marshal)处理,并使用strings.Contains检查我希望包含在XML中的行是否确实存在。但是,我想区分实际xml与所需xml。目前,我的代码看起来像这样:func(suite*BookSuite)TestXMLMarshal(){priceXML,priceErr:=xml.Marshal(PriceType{Price:10,Type:"IND"})suite.Nil(priceErr)linePresent:=strings.Contains(string(priceXML),``)iftrue!=linePresent{err

http - 去 Gin 框架 : Testing query and POST with cURL

我正在尝试theREADMEofginframework中的代码示例(“另一个例子:查询+发布表单”):packagemainimport("fmt""github.com/gin-gonic/gin")funcmain(){router:=gin.Default()router.POST("/post",func(c*gin.Context){id:=c.Query("id")page:=c.DefaultQuery("page","0")name:=c.PostForm("name")message:=c.PostForm("message")fmt.Printf("id:%s;p

unit-testing - 如何为测试目的重新定义/模拟 Go 中的方法?

我正在为Go库创建测试。我发现了一个错误:cannotassignto我有以下代码(https://play.golang.org/p/kf0gANb-p-):packagemainimport("bytes""fmt""os/exec""strconv""strings")const(CONSOLE="dialog"KDE="kdialog"GTK="gtkdialog"X="Xdialog"DIALOG_TEST_ENV="test_env"AUTO="auto")const(DIALOG_ERR_CANCEL="exitstatus1"DIALOG_ERR_HELP="exits

unit-testing - 如何用reflect测试方法?

我有一个Sync()方法可以覆盖在环境中设置的Config字段值。环境变量名称是通过下划线和大写名称从配置字段派生的。例如。AppName会有一个对应的环境变量APP_NAME请帮我测试以下情况。有复杂的东西,比如https://golang.org/pkg/reflect/#Value.Set:Setassignsxtothevaluev.ItpanicsifCanSetreturnsfalse.AsinGo,x'svaluemustbeassignabletov'stype.所以我不知道如何测试这个案例?import("encoding/json""errors""fmt""os"

unit-testing - go 模板的示例测试因导入和未使用 : "testing" 而失败

据我所知,我正在完美地遵循“进行测试”所需的结构。我没有发现与我可以在其他包中运行的测试有差异。“去build”工作正常。我得到了./HelloTemplate_test.go:3:importedandnotused:"testing"./HelloTemplate_test.go:5:undefined:TestinginTesting.T我错过了什么?HelloTemplate.gopackagetemplateprintimport"testing"funcTestRunTempl(t*Testing.T){sweaters:=Inventory{"wool",17}tmpl:

testing - Go-lang测试,Benchmark上Parallel Setting是什么意思?

在https://golang.org/pkg/testing/描述了我们可以使用testing.B.RunParallel()函数在并行设置中运行基准测试。我尝试编写简单的测试代码:funcBenchmarkFunctionSome(b*testing.B){fori:=0;i然后我将其更改为使用RunParallel()funcBenchmarkFunctionSome(b*testing.B){b.RunParallel(func(pb*testing.PB){forpb.Next(){SomeFunction()}})}并且使用RunParallel()的比第一个基准测试慢。其

git - 在 Heroku 上部署 revel 应用程序

我正在尝试在heroku中部署一个应用程序。我正在使用revel框架,但是(我不知道这是否会成为一个问题)我之前没有使用过该框架......但是昨天我将我的代码移到了该框架中。Web应用程序在本地运行,但不能部署在heroku中。这是我尝试“gitpushherokumaster”时的输出Countingobjects:46,done.Deltacompressionusingupto4threads.Compressingobjects:100%(41/41),done.Writingobjects:100%(46/46),135.45KiB|0bytes/s,done.Total4