Uploaded image for project: 'Apache YuniKorn'
  1. Apache YuniKorn
  2. YUNIKORN-2590

Handler tests should check for nil request on create

    XMLWordPrintableJSON

Details

    Description

      In the handler_test.go file we have an anti pattern showing a large number (40+) warnings in an IDE:

      'req' might have 'nil' or other unexpected value as its corresponding error variable might be not 'nil'

      The warning are due to the fact that we have the following pattern:

      req, err = http.NewRequest("GET", "path", strings.NewReader(""))
      req = req.WithContext(context.WithValue(req.Context(), httprouter.ParamsKey, httprouter.Params{}))

      There is no error assertion after the request creation. We should add a simple assert.NilError(t, err, "HTTP request create failed") inserted between creating and using the request.

      Attachments

        Issue Links

          Activity

            People

              ryankert Hsien-Cheng(Ryan) Huang
              wilfreds Wilfred Spiegelenburg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: