小编Kyo*_*yoo的帖子

如何动态更新复选框的react-json-schema表单

我有这样的代码

const Jschema = {
    "type": "object",
    "title": "Create Form",
    "required": [
        "level1",
        "level2"
    ],
    "properties": {
        "level1": {
            "type": "string",
            "title": "Level 1",
            "default": ""
        },
        "level2": {
          "type": "array",
          "items": {
              "enum": [
                  "no position"
              ],
              "type": "string"
          },
          "title": "Level 2",
          "uniqueItems": true
        },
    },
    "description": "Create Form"
  }

  const uiSchema = {
    "ui:order": [
        "level1",
        "level2"
    ],

    "level1": {
        "ui:title": "Rank Level 1",
        "ui:widget": "dropdown",
        "ui:placeholder": "Please select rank level 1"
    },
    "level2": {
      "ui:title": "Rank …
Run Code Online (Sandbox Code Playgroud)

javascript arrays arraylist reactjs react-jsonschema-forms

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

如何使用 ` func(w http.ResponseWriter, r *http.Request) ` 进行模拟测试

当我想从模拟中获取响应主体时,我遇到了问题,目前我已经创建了一些像这样的模拟:

func (m *MockCarService) GetCar(ctx context.Context, store store.Store, IDCar uint) (interface{}, error) {

    call := m.Called(ctx, store)
    res := call.Get(0)
    if res == nil {
        return nil, call.Error(1)
    }
    return res.(*models.Cars), call.Error(1)
}
Run Code Online (Sandbox Code Playgroud)

然后我像这样创建 handler_test.go :

func TestGetCar(t *testing.T) {

    var store store.Store

    car := &models.Cars{
        ID:          12345,
        BrandID:     1,
        Name:        "Car abc",
        Budget:      2000,
        CostPerMile: 4000,
        KpiReach:    6000,
    }

    mockService := func() *service.MockCarService {
        svc := &service.MockCarService{}
        svc.On("GetCar", context.Background(), car.ID).Return(car, nil)
        return svc
    }

    handlerGet := NewCarHandler(mockService())
    actualResponse := …
Run Code Online (Sandbox Code Playgroud)

unit-testing http mocking httphandler go

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