On Wed, Jan 5, 2022 at 11:32 AM Brieuc Jeunhomme wrote:
>
> So:
> $ cat mypackage.go
> package mypackage
>
> import "something/something/foo"
>
> func MyFunction() {
> some code
> some code
> some code
> foo.Bar(make(chan foo.Baz), make(chan foo.Foobar))
> }
>
> Is the code I would r
On Wed, Jan 5, 2022 at 11:32 AM Brieuc Jeunhomme
wrote:
> So:
> $ cat mypackage.go
> package mypackage
>
> import "something/something/foo"
>
> func MyFunction() {
> some code
> some code
> some code
> foo.Bar(make(chan foo.Baz), make(chan foo.Foobar))
> }
>
> Is the code I would re
I'm also confused.
On Wed, Jan 5, 2022 at 11:09 AM Brieuc Jeunhomme
wrote:
> For example, let's say you want to unit test MyFunction, which calls
> foo.Bar(chan foo.Baz, chan foo.Foobar) and foo compiles only under a single
> OS. If you want to write a portable unit test for MyFunction, you can
So:
$ cat mypackage.go
package mypackage
import "something/something/foo"
func MyFunction() {
some code
some code
some code
foo.Bar(make(chan foo.Baz), make(chan foo.Foobar))
}
Is the code I would really like to write.
foo has build constraints. As you can see, my code doesn't, i
On Wed, Jan 5, 2022 at 11:09 AM Brieuc Jeunhomme wrote:
> But here ,since under non-windows platforms, I can't import the package, it
> means I have to define wrappers for everything I use: types, constants,
> functions.
I don't get it. Put the common code in a file/in files with no build
cons
Yes, that's what I wanted to do, but it looks very tedious at best. In
"normal" unit tests, it's simple: import the package you're using, inject
its functions, reuse its types and constants.
But here ,since under non-windows platforms, I can't import the package, it
means I have to define wrap
On Tue, 2022-01-04 at 08:29 -0800, Brieuc Jeunhomme wrote:
> Hi,
>
> I'm writing code that uses the golang.org/x/sys/windows/svc package.
> This package compiles only for windows builds, for other GOOS values,
> I get a build error. That's fair, but I'm wondering how to unit test
> the code that c