-2

During testing I get the error message

Expected
        <[]map[string]interface {} | len:0, cap:0>: []
    to equal
        <[]map[string]interface {} | len:0, cap:0>: nil

How Do i declare a []map[string]interface {} to be "nil"?

thank you

colm.anseo
  • 19,337
  • 4
  • 43
  • 52
benwasin97
  • 203
  • 4
  • 12

1 Answers1

1

You can use the gomega matchers like this:

Describe("the test", func() {
    var obj []map[string]interface{}

    It("should be nil", func() {
        Expect(obj).To(BeNil())
    })

    It("should be empty []", func() {
        Expect(obj).To(BeEmpty())
    })
})

These tests will pass if the value is not initialized also.

This is how you can declare the map[string]interface{} to be nil:

var obj []map[string]interface{}
// OR
var obj []map[string]interface{} = nil
advay rajhansa
  • 1,129
  • 9
  • 17