本文整理汇总了Golang中testing.T.Skipped方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Skipped方法的具体用法?Golang T.Skipped怎么用?Golang T.Skipped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.T
的用法示例。
在下文中一共展示了T.Skipped方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestWriteExtraInvalid
func TestWriteExtraInvalid(t *testing.T) {
src := `
[foo]
hello=world
`
src2 := `
[foo]
goodbye=all
herp?
other=data
`
expBytes := 27
file, err := Load(strings.NewReader(src))
if err != nil {
t.Skipped()
}
n, err := file.Write([]byte(src2))
if n != expBytes {
t.Errorf("Expected to write %d bytes, got %d", expBytes, n)
}
if err == nil {
t.Errorf("Expected an error on partial write, got none")
}
check := func(section, key, expect string) {
checkStr(t, file, section, key, expect)
}
check("foo", "hello", "world")
check("foo", "goodbye", "all")
}
示例2: TestWriteExtra
func TestWriteExtra(t *testing.T) {
src := `
[foo]
hello=world
`
src2 := `
[foo]
goodbye=all
[bar]
other=data
`
expBytes := len(src2)
file, err := Load(strings.NewReader(src))
if err != nil {
t.Skipped()
}
n, err := file.Write([]byte(src2))
if n != expBytes {
t.Errorf("Expected to write %d bytes, got %d", expBytes, n)
}
check := func(section, key, expect string) {
checkStr(t, file, section, key, expect)
}
check("foo", "hello", "world")
check("foo", "goodbye", "all")
check("bar", "other", "data")
}
示例3: initTestServer
func initTestServer(t *testing.T) (*testutil.TestServer, *api.Client) {
if testing.Short() {
t.Skip("skipping test dependent on consul because of short mode")
}
defer func() {
// if consul is not in the $PATH, NewTestServer will skip the test,
// which should be treated as an error
if t.Skipped() {
t.Error("failing skipped test")
}
}()
server := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
ports := getPorts(t, 6)
c.Ports = &testutil.TestPortConfig{
DNS: ports[0],
HTTP: ports[1],
RPC: ports[2],
SerfLan: ports[3],
SerfWan: ports[4],
Server: ports[5],
}
})
client, err := api.NewClient(&api.Config{
Address: server.HTTPAddr,
})
if err != nil {
t.Fatal(err)
}
return server, client
}
示例4: dependOn
func dependOn(t *testing.T, deps ...func(*testing.T)) {
for _, dependancy := range deps {
dependancy(t)
if t.Skipped() || t.Failed() {
t.Skip("Dependency failed, Skipping.")
}
}
}
示例5: dependOn
func dependOn(t *testing.T, deps ...func(*testing.T)) {
// stops things getting logged into other test logs
temp := new(testing.T)
for _, dependancy := range deps {
dependancy(temp)
if temp.Skipped() || temp.Failed() {
t.Skip("Dependency failed, Skipping.")
}
}
}
示例6: makeStore
func makeStore(t *testing.T) (kp.Store, *testutil.TestServer) {
if testing.Short() {
t.Skip("skipping test dependendent on consul because of short mode")
}
// testutil.NewTestServerConfig will skip the test if "consul" isn't in the system path.
// We'd rather the test fail.
defer func() {
if t.Skipped() {
t.Fatalf("test skipped by testutil package")
}
}()
// Create server
server := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
// consul output in test output is noisy
c.Stdout = ioutil.Discard
c.Stderr = ioutil.Discard
// If ports are left to their defaults, this test conflicts
// with the test consul servers in pkg/kp
var offset uint64
idx := int(atomic.AddUint64(&offset, 1))
c.Ports = &testutil.TestPortConfig{
DNS: 26000 + idx,
HTTP: 27000 + idx,
RPC: 28000 + idx,
SerfLan: 29000 + idx,
SerfWan: 30000 + idx,
Server: 31000 + idx,
}
})
client := kp.NewConsulClient(kp.Options{
Address: server.HTTPAddr,
})
store := kp.NewConsulStore(client)
return store, server
}
示例7: NewConsulTestFixture
// Create a new test fixture that spins up a local Consul server.
func NewConsulTestFixture(t *testing.T) *ConsulTestFixture {
if testing.Short() {
t.Skip("skipping test dependent on consul because of short mode")
}
// testutil.NewTestServerConfig will skip the test if "consul" isn't in the system path.
// We'd rather the test fail.
defer func() {
if t.Skipped() {
t.Error("failing skipped test")
}
}()
server := testutil.NewTestServer(t)
client := NewConsulClient(Options{
Address: server.HTTPAddr,
})
store := NewConsulStore(client)
return &ConsulTestFixture{
TestServer: server,
Store: store,
Client: client,
T: t,
}
}
示例8: TestAddPatternsFromPathFileOpenErr
func TestAddPatternsFromPathFileOpenErr(t *testing.T) {
t.Skipped()
}