小编Iva*_*tos的帖子

用bash替换yml中一行的值

web:
  image: nginx
  volumes:
    - "./app:/src/app"
  ports:
    - "3030:3000"
    - "35729:35729"
Run Code Online (Sandbox Code Playgroud)

我想有一个bash脚本用bash脚本替换nginxfor参数.

./script apache
Run Code Online (Sandbox Code Playgroud)

将替换nginxapache

bash shell yaml

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

使用Rspec测试DELETE请求的最佳方法是什么?

我开始用这种方式:

  describe "DELETE /v1/categories/{id}" do
   before(:each) do
     #   Login User/Token
   end
   it 'deletes a category' do
     category = Fabricate(:category)
     category2 = Fabricate(:category)

     get "/v1/categories"
     expect(response.status).to eq 200
     expect(JSON.parse(response.body)).to eq([YAML.load(category.to_json),YAML.load(category2.to_json),])

     delete "/v1/categories/#{category.id}"
     expect(response.status).to eq 200

     get "/v1/categories"
     expect(JSON.parse(response.body)).to eq([YAML.load(category2.to_json)])
   end
 end
Run Code Online (Sandbox Code Playgroud)

我不确定是否是测试API请求删除数据的最佳方法.

api rspec ruby-on-rails request http-delete

5
推荐指数
1
解决办法
1万
查看次数

Convert sqlx.DB to sql.DB in Go

What's the best way to convert the type sqlx.DB (jmoiron/sqlx) to sql.DB (database/sql)?

I'm currently using the package github.com/golang-migrate/migrate and it requires an existing connection to follow sql.DB interface.


func Migrate(db *sqlx.DB) error {
    driver, err := postgres.WithInstance(db, &postgres.Config{})
    m, err := migrate.NewWithDatabaseInstance(
        "file://src/db/migrations",
        "postgres", driver)
    if err != nil {
        return err
    }

    return m.Up()
}
Run Code Online (Sandbox Code Playgroud)

Update: I mixed the description and added more details. The title was correct.

sql go

1
推荐指数
2
解决办法
861
查看次数

标签 统计

api ×1

bash ×1

go ×1

http-delete ×1

request ×1

rspec ×1

ruby-on-rails ×1

shell ×1

sql ×1

yaml ×1