github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/engine/devlist_test.go (about)

     1  // Copyright 2015 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  package engine
     5  
     6  import "testing"
     7  
     8  func TestDeviceList(t *testing.T) {
     9  	tc := SetupEngineTest(t, "devicelist")
    10  	defer tc.Cleanup()
    11  
    12  	CreateAndSignupFakeUserPaper(tc, "login")
    13  
    14  	eng := NewDevList(tc.G)
    15  	m := NewMetaContextForTestWithLogUI(tc)
    16  	if err := RunEngine2(m, eng); err != nil {
    17  		t.Fatal(err)
    18  	}
    19  	if len(eng.List()) != 2 {
    20  		for i, d := range eng.List() {
    21  			t.Logf("%d: %+v", i, d)
    22  		}
    23  		t.Errorf("devices: %d, expected 2", len(eng.List()))
    24  	}
    25  	// Check that the device times are all actually set.
    26  	for _, d := range eng.List() {
    27  		if d.CTime == 0 {
    28  			t.Fatal("CTime not set")
    29  		}
    30  		if d.MTime == 0 {
    31  			t.Fatal("MTime not set")
    32  		}
    33  		if d.LastUsedTime == 0 {
    34  			t.Fatal("LastUsedTime not set")
    35  		}
    36  	}
    37  }