(t *testing.T)
| 25 | } |
| 26 | |
| 27 | func TestNewCanModule(t *testing.T) { |
| 28 | s := createMockSession(t) |
| 29 | mod := NewCanModule(s) |
| 30 | |
| 31 | if mod == nil { |
| 32 | t.Fatal("NewCanModule returned nil") |
| 33 | } |
| 34 | |
| 35 | if mod.Name() != "can" { |
| 36 | t.Errorf("Expected name 'can', got '%s'", mod.Name()) |
| 37 | } |
| 38 | |
| 39 | if mod.Author() != "Simone Margaritelli <evilsocket@gmail.com>" { |
| 40 | t.Errorf("Unexpected author: %s", mod.Author()) |
| 41 | } |
| 42 | |
| 43 | if mod.Description() == "" { |
| 44 | t.Error("Empty description") |
| 45 | } |
| 46 | |
| 47 | // Check default values |
| 48 | if mod.transport != "can" { |
| 49 | t.Errorf("Expected default transport 'can', got '%s'", mod.transport) |
| 50 | } |
| 51 | |
| 52 | if mod.deviceName != "can0" { |
| 53 | t.Errorf("Expected default device 'can0', got '%s'", mod.deviceName) |
| 54 | } |
| 55 | |
| 56 | if mod.dumpName != "" { |
| 57 | t.Errorf("Expected empty dumpName, got '%s'", mod.dumpName) |
| 58 | } |
| 59 | |
| 60 | if mod.dumpInject { |
| 61 | t.Error("Expected dumpInject to be false by default") |
| 62 | } |
| 63 | |
| 64 | if mod.filter != "" { |
| 65 | t.Errorf("Expected empty filter, got '%s'", mod.filter) |
| 66 | } |
| 67 | |
| 68 | // Check DBC and OBD2 |
| 69 | if mod.dbc == nil { |
| 70 | t.Error("DBC should not be nil") |
| 71 | } |
| 72 | |
| 73 | if mod.obd2 == nil { |
| 74 | t.Error("OBD2 should not be nil") |
| 75 | } |
| 76 | |
| 77 | // Check handlers |
| 78 | handlers := mod.Handlers() |
| 79 | expectedHandlers := []string{ |
| 80 | "can.recon on", |
| 81 | "can.recon off", |
| 82 | "can.clear", |
| 83 | "can.show", |
| 84 | "can.dbc.load NAME", |
nothing calls this directly
no test coverage detected