Skip to content

Commit

Permalink
Fix tests attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
raynaudoe committed Mar 14, 2024
1 parent 9c8fed0 commit 9de4bda
Show file tree
Hide file tree
Showing 5 changed files with 595 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ regenerate: install
make -C test/issue620 regenerate
make -C test/protobuffer regenerate
make -C test/issue630 regenerate
make -C test/testdata regenerate

make gofmt

Expand Down
30 changes: 30 additions & 0 deletions test/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Protocol Buffers for Go with Gadgets
#
# Copyright (c) 2013, The GoGo Authors. All rights reserved.
# http://github.com/cosmos/gogoproto
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

regenerate:
cd .. && (protoc --proto_path=../:../protobuf/:. --gogo_out=Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any:. testdata/testdata.proto)
84 changes: 84 additions & 0 deletions test/testdata/animal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package testdata

// nolint

import (
"fmt"
"github.com/cosmos/gogoproto/proto"
types "github.com/cosmos/gogoproto/types/any"
)

type Animal interface {
proto.Message

Greet() string
}

type Cartoon interface {
proto.Message

Identify() string
}

func (c *Cat) Greet() string {
return fmt.Sprintf("Meow, my name is %s", c.Moniker)
}

func (c *Bird) Identify() string {
return "This is Tweety."
}

func (d Dog) Greet() string {
return fmt.Sprintf("Roof, my name is %s", d.Name)
}

var _ types.UnpackInterfacesMessage = HasAnimal{}

func (m HasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error {
var animal Animal
return unpacker.UnpackAny(m.Animal, &animal)
}

type HasAnimalI interface {
TheAnimal() Animal
}

var _ HasAnimalI = &HasAnimal{}

func (m HasAnimal) TheAnimal() Animal {
return m.Animal.GetCachedValue().(Animal)
}

type HasHasAnimalI interface {
TheHasAnimal() HasAnimalI
}

var _ HasHasAnimalI = &HasHasAnimal{}

func (m HasHasAnimal) TheHasAnimal() HasAnimalI {
return m.HasAnimal.GetCachedValue().(HasAnimalI)
}

var _ types.UnpackInterfacesMessage = HasHasAnimal{}

func (m HasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error {
var animal HasAnimalI
return unpacker.UnpackAny(m.HasAnimal, &animal)
}

type HasHasHasAnimalI interface {
TheHasHasAnimal() HasHasAnimalI
}

var _ HasHasAnimalI = &HasHasAnimal{}

func (m HasHasHasAnimal) TheHasHasAnimal() HasHasAnimalI {
return m.HasHasAnimal.GetCachedValue().(HasHasAnimalI)
}

var _ types.UnpackInterfacesMessage = HasHasHasAnimal{}

func (m HasHasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error {
var animal HasHasAnimalI
return unpacker.UnpackAny(m.HasHasAnimal, &animal)
}
Loading

0 comments on commit 9de4bda

Please sign in to comment.