mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 09:54:47 +01:00
efe7b17d21
From: github.com/golang/protobuf v1.3.2 google.golang.org/grpc v1.17.0 To: github.com/golang/protobuf v1.4.3 google.golang.org/grpc v1.35.0 google.golang.org/protobuf v1.25.0 About the two protobuf packages: https://developers.google.com/protocol-buffers/docs/reference/go/faq > Version v1.4.0 and higher of github.com/golang/protobuf wrap the new implementation and permit programs to adopt the new API incrementally. For example, the well-known types defined in github.com/golang/protobuf/ptypes are simply aliases of those defined in the newer module. Thus, google.golang.org/protobuf/types/known/emptypb and github.com/golang/protobuf/ptypes/empty may be used interchangeably. Notable Code Changes in zrepl: - generate protobufs now contain a mutex so we can't copy them by value anymore - grpc.WithDialer is deprecated => use grpc.WithContextDialer instead Go1.12 is now actually required by some of the dependencies.
70 lines
1.1 KiB
Go
70 lines
1.1 KiB
Go
package pdu
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFilesystemVersion_RelName(t *testing.T) {
|
|
|
|
type TestCase struct {
|
|
In *FilesystemVersion
|
|
Out string
|
|
Panic bool
|
|
}
|
|
|
|
creat := FilesystemVersionCreation(time.Now())
|
|
tcs := []TestCase{
|
|
{
|
|
In: &FilesystemVersion{
|
|
Type: FilesystemVersion_Snapshot,
|
|
Name: "foobar",
|
|
Creation: creat,
|
|
},
|
|
Out: "@foobar",
|
|
},
|
|
{
|
|
In: &FilesystemVersion{
|
|
Type: FilesystemVersion_Bookmark,
|
|
Name: "foobar",
|
|
Creation: creat,
|
|
},
|
|
Out: "#foobar",
|
|
},
|
|
{
|
|
In: &FilesystemVersion{
|
|
Type: 2342,
|
|
Name: "foobar",
|
|
Creation: creat,
|
|
},
|
|
Panic: true,
|
|
},
|
|
}
|
|
|
|
for _, tc := range tcs {
|
|
if tc.Panic {
|
|
assert.Panics(t, func() {
|
|
tc.In.RelName()
|
|
})
|
|
} else {
|
|
o := tc.In.RelName()
|
|
assert.Equal(t, tc.Out, o)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
func TestFilesystemVersion_ZFSFilesystemVersion(t *testing.T) {
|
|
|
|
empty := &FilesystemVersion{}
|
|
_, err := empty.ZFSFilesystemVersion()
|
|
assert.Error(t, err)
|
|
|
|
dateInvalid := &FilesystemVersion{Creation: "foobar"}
|
|
_, err = dateInvalid.ZFSFilesystemVersion()
|
|
assert.Error(t, err)
|
|
|
|
}
|