Skip to content

Commit 6537c9a

Browse files
committed
chore: more tests
Signed-off-by: Giau. Tran Minh <[email protected]>
1 parent 5bbd21a commit 6537c9a

File tree

5 files changed

+80
-2
lines changed

5 files changed

+80
-2
lines changed

Diff for: internal/wire/testdata/Subtract/foo/wire.go

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
package main
1919

2020
import (
21-
// "strings"
22-
2321
"github.com/google/wire"
2422
)
2523

Diff for: internal/wire/testdata/SubtractErrors/foo/foo.go

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2018 The Wire Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"github.com/google/wire"
19+
)
20+
21+
type context struct{}
22+
23+
func main() {}
24+
25+
type FooOptions struct{}
26+
type Foo string
27+
type Bar struct{}
28+
type BarName string
29+
30+
func provideFooOptions() *FooOptions {
31+
return &FooOptions{}
32+
}
33+
34+
func provideFoo(*FooOptions) Foo {
35+
return Foo("foo")
36+
}
37+
38+
func provideBar(Foo, BarName) *Bar {
39+
return &Bar{}
40+
}
41+
42+
var Set = wire.NewSet(
43+
provideFooOptions,
44+
provideFoo,
45+
provideBar,
46+
)

Diff for: internal/wire/testdata/SubtractErrors/foo/wire.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2018 The Wire Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build wireinject
16+
// +build wireinject
17+
18+
package main
19+
20+
import (
21+
"github.com/google/wire"
22+
)
23+
24+
func injectNonSet(opts *FooOptions) Foo {
25+
panic(wire.Build(wire.Subtract(provideFoo, new(FooOptions))))
26+
}
27+
28+
func injectNonPointer(name BarName, opts *FooOptions) *Bar {
29+
panic(wire.Build(wire.Subtract(Set, FooOptions{})))
30+
}

Diff for: internal/wire/testdata/SubtractErrors/pkg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example.com/foo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
example.com/foo/wire.go:x:y: first argument to Subtract must be a Set
2+
3+
example.com/foo/wire.go:x:y: argument to Subtract must be a pointer

0 commit comments

Comments
 (0)