dongxun7301 2019-09-18 21:10
浏览 51

我应该如何执行到Azure云存储的集成测试

I am trying to create integration tests for a Go application that sends reads configurations, reads a file, and uploads this file to Azure Cloud Storage. The code for the application is written, but I'm not entirely sure how I would create integration tests for it, or if I my idea of integration tests is even appropriate for the problem.

I've been trying to create tests that mock away the Connection to the datastore, but I'm having trouble understanding how I would even go about doing that.

main.go:
main (){
//reads in azureConnectionDetails
upload, err := azure.NewUpload(azureConnectionDetails, inChannel, outChannel)
upload.SendFileWhenMessageRecieved()
inChannel <- file
}
azure.go:
NewUpload (azureConnectionDetails, inChannel, outChannel){
ds, err := datastore.ConnectToDataStore(azureConnectionDetails)
return upload{ds}
}

SendFileWhenMessageReceived(){
//Sends the file to outChannel when the file is sent to inChannel
}
datastore.go
ConnectToDataStore(){
//connects to azure
//returns ds
}

I can run "main" when I run "go test", but when the program gets to the part where it tries to connect to Azure it throws an error, because I don't provide credentials to connect to a real instance of Azure. That makes sense of course, however I don't want to connect to a real instance.

Is there a way I can mock away this connection to Azure with how my code is set up already? What would I have to change?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于#flink#的问题:关于docker部署flink集成hadoop的yarn,请教个问题flink启动yarn-session.sh连不上hadoop
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题