This repository was archived by the owner on Jun 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 14 files changed +479
-52
lines changed
internal/tests/import_embedded_interface Expand file tree Collapse file tree 14 files changed +479
-52
lines changed Original file line number Diff line number Diff line change 1
1
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 /go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w =
2
+ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628 =
2
3
golang.org/x/net v0.0.0-20190311183353-d8887717615a /go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg =
3
4
golang.org/x/sync v0.0.0-20190423024810-112230192c58 /go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM =
4
5
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a /go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY =
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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:generate mockgen -destination bugreport_mock.go -package bugreport -source=bugreport.go
16
+
17
+ package bugreport
18
+
19
+ import (
20
+ "log"
21
+
22
+ "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/ersatz"
23
+ "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/faux"
24
+ )
25
+
26
+ // Source is an interface w/ an embedded foreign interface
27
+ type Source interface {
28
+ ersatz.Embedded
29
+ faux.Foreign
30
+ }
31
+
32
+ func CallForeignMethod (s Source ) {
33
+ log .Println (s .Ersatz ())
34
+ log .Println (s .OtherErsatz ())
35
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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
+ package bugreport
15
+
16
+ import (
17
+ "testing"
18
+
19
+ "github.com/golang/mock/gomock"
20
+ )
21
+
22
+ // TestValidInterface assesses whether or not the generated mock is valid
23
+ func TestValidInterface (t * testing.T ) {
24
+ ctrl := gomock .NewController (t )
25
+ defer ctrl .Finish ()
26
+
27
+ s := NewMockSource (ctrl )
28
+ s .EXPECT ().Ersatz ().Return ("" )
29
+ s .EXPECT ().OtherErsatz ().Return ("" )
30
+ CallForeignMethod (s )
31
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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
+ package ersatz
15
+
16
+ type Embedded interface {
17
+ Ersatz () Return
18
+ }
19
+
20
+ type Return interface {}
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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
+ package faux
15
+
16
+ import "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/log"
17
+
18
+ func Conflict1 () {
19
+ log .Foo ()
20
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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
+ package faux
15
+
16
+ import (
17
+ "log"
18
+
19
+ "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/ersatz"
20
+ )
21
+
22
+ type Foreign interface {
23
+ ersatz.Embedded
24
+ }
25
+
26
+ func Conflict0 () {
27
+ log .Println ()
28
+ }
Original file line number Diff line number Diff line change
1
+ //
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ //
14
+ //go:generate mockgen -destination net_mock.go -package bugreport -source=net.go
15
+ package bugreport
16
+
17
+ import "net/http"
18
+
19
+ type Net interface {
20
+ http.ResponseWriter
21
+ }
22
+
23
+ func CallResponseWriterMethods (n Net ) {
24
+ n .WriteHeader (10 )
25
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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
+ package bugreport
15
+
16
+ import (
17
+ "testing"
18
+
19
+ "github.com/golang/mock/gomock"
20
+ )
21
+
22
+ // TestValidInterface assesses whether or not the generated mock is valid
23
+ func TestValidNetInterface (t * testing.T ) {
24
+ ctrl := gomock .NewController (t )
25
+ defer ctrl .Finish ()
26
+
27
+ s := NewMockNet (ctrl )
28
+ s .EXPECT ().WriteHeader (10 )
29
+ CallResponseWriterMethods (s )
30
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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
+ package ersatz
15
+
16
+ type Embedded interface {
17
+ OtherErsatz () Return
18
+ }
19
+
20
+ type Return interface {}
Original file line number Diff line number Diff line change
1
+ // Copyright 2020 Google Inc.
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
+ // http://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
+ package log
15
+
16
+ func Foo () {}
You can’t perform that action at this time.
0 commit comments