Skip to content

Commit 2974eba

Browse files
authored
add defer tc.Cleanup() (keybase#17415)
* add defer tc.Cleanup() * fix
1 parent 4948372 commit 2974eba

45 files changed

Lines changed: 129 additions & 36 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎go/chat/active_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111

1212
func TestChatActive(t *testing.T) {
1313
ctx, world, _, _, _, _ := setupTest(t, 1)
14+
defer world.Cleanup()
1415

1516
u := world.GetUsers()[0]
1617
tc := world.Tcs[u.Username]
17-
defer tc.Cleanup()
1818
g := globals.NewContext(tc.G, tc.ChatG)
1919
log := utils.NewDebugLabeler(g.GetLog(), "TestChatActive", false)
2020

‎go/chat/boxer_test.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,14 +910,16 @@ func TestChatMessageSenderMismatch(t *testing.T) {
910910
require.Error(t, err, "should not unbox with sender mismatch")
911911
})
912912

913+
tc := libkb.SetupTest(t, "batch", 0)
914+
defer tc.Cleanup()
915+
913916
// Just check that batch fetching of device encryption keys work.
914917
// Use the 4 users we've collected in this test.
915918
var uvs []keybase1.UserVersion
916919
for _, uid := range allUIDs {
917920
uvs = append(uvs, keybase1.UserVersion{Uid: uid})
918921
}
919-
tc := libkb.SetupTest(t, "batch", 0)
920-
defer tc.Cleanup()
922+
921923
keys, err := batchLoadEncryptionKIDs(context.TODO(), tc.G, uvs)
922924
require.NoError(t, err, "no error")
923925
require.Equal(t, len(keys), len(uvs), "one key per user")

‎go/chat/commands/flip_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616

1717
func TestFlipPreview(t *testing.T) {
1818
tc := externalstest.SetupTest(t, "flip", 0)
19+
defer tc.Cleanup()
20+
1921
ui := kbtest.NewChatUI()
2022
g := globals.NewContext(tc.G, &globals.ChatContext{})
2123
g.CoinFlipManager = types.DummyCoinFlipManager{}
@@ -64,5 +66,4 @@ func TestFlipPreview(t *testing.T) {
6466
require.Fail(t, "no text expected")
6567
default:
6668
}
67-
6869
}

‎go/chat/commands/giphy_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ func (d *testGiphySearcher) Search(mctx libkb.MetaContext, query *string, limit
5757

5858
func TestGiphyPreview(t *testing.T) {
5959
tc := externalstest.SetupTest(t, "giphy", 0)
60+
defer tc.Cleanup()
61+
6062
g := globals.NewContext(tc.G, &globals.ChatContext{})
6163
giphy := NewGiphy(g)
6264
searcher := newTestGiphySearcher()

‎go/chat/flipmanager_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ func TestFlipManagerChannelFlip(t *testing.T) {
298298

299299
func TestFlipManagerParseEdges(t *testing.T) {
300300
tc := externalstest.SetupTest(t, "flip", 0)
301+
defer tc.Cleanup()
302+
301303
g := globals.NewContext(tc.G, &globals.ChatContext{})
302304
fm := NewFlipManager(g, nil)
303305
testCase := func(text string, ftyp flip.FlipType, refMetadata flipTextMetadata) {

‎go/chat/storage/inbox_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ func TestInboxSync(t *testing.T) {
734734

735735
func TestInboxServerVersion(t *testing.T) {
736736
tc, inbox, uid := setupInboxTest(t, "basic")
737+
defer tc.Cleanup()
737738

738739
// Create an inbox with a bunch of convos, merge it and read it back out
739740
numConvs := 10

‎go/chat/unfurl/unfurler_test.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ type dummyDeliverer struct {
6969
func (d dummyDeliverer) ForceDeliverLoop(ctx context.Context) {}
7070

7171
func TestUnfurler(t *testing.T) {
72+
tc := externalstest.SetupTest(t, "unfurler", 0)
73+
defer tc.Cleanup()
74+
7275
log := logger.NewTestLogger(t)
7376
store := attachments.NewStoreTesting(log, nil)
7477
s3signer := &ptsigner{}
75-
tc := externalstest.SetupTest(t, "unfurler", 0)
7678
g := globals.NewContext(tc.G, &globals.ChatContext{})
7779
notifier := makeDummyActivityNotifier()
7880
g.ChatContext.ActivityNotifier = notifier

‎go/chat/utils/collapses_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515

1616
func TestCollapses(t *testing.T) {
1717
tc := externalstest.SetupTest(t, "collapses", 0)
18+
defer tc.Cleanup()
19+
1820
g := globals.NewContext(tc.G, &globals.ChatContext{})
1921
collapses := NewCollapses(g)
2022

‎go/chat/utils/utils_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ func (c configUsernamer) GetUsername() libkb.NormalizedUsername {
263263

264264
func TestAddUserToTlfName(t *testing.T) {
265265
tc := externalstest.SetupTest(t, "chat-utils", 0)
266+
defer tc.Cleanup()
267+
266268
g := globals.NewContext(tc.G, &globals.ChatContext{})
267269
g.Env.SetConfig(
268270
&configUsernamer{g.Env.GetConfig(), "charlie"}, g.Env.GetConfigWriter())

‎go/chat/wallet/sender_test.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ func (m *mockUpakLoader) LookupUsername(ctx context.Context, uid keybase1.UID) (
8282
}
8383

8484
func TestStellarSender(t *testing.T) {
85+
tc := externalstest.SetupTest(t, "stellarsender", 0)
86+
defer tc.Cleanup()
87+
8588
mikeUID := gregor1.UID([]byte{0, 1})
8689
patrickUID := gregor1.UID([]byte{0, 2})
8790
maxUID := gregor1.UID([]byte{0, 4})
8891
convID := chat1.ConversationID([]byte{0, 3})
89-
tc := externalstest.SetupTest(t, "stellarsender", 0)
9092
ms := mockStellar{}
9193
mi := mockInboxSource{}
9294
mu := newMockUpakLoader()

0 commit comments

Comments
 (0)