Hi,

I would like check if a dummy function returns the desired error.
To do this, I put desired error type on test cases struct (the error
field is required in the struct).

On test-error.go, I have:

```
package tester

import (
        "fmt"
)

type eTest struct {
        what    string
}

func (e *eTest) Error() string {
        return fmt.Sprintf("e.what? %s", e.what)
}

func Err() error {
        return &eTest{"what?"}
}
```

And on the corresponding test (test-error_test.go), I have:

```
package tester

import (
        "testing"
)

type Tests struct {
        err error
}

func TestErr (t *testing.T) {
        cases := Tests{eTest,}

        t.Run("now testing", func (t *testing.T) {
                actual := Err()

                if actual != cases.err {
                        t.Errorf("eh")
                }
        })
}
```

But when I `go test`, I got build error:

```
# test-error [test-error.test]
./test-error_test.go:12:17: eTest (type) is not an expression
```

What was wrong above?

-- 
An old man doll... just what I always wanted! - Clara

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4b518929-1d31-81b2-02bc-a510f6bf93ef%40gmail.com.

Reply via email to