| package lib |
| import ( |
| "testing" |
| "mojom/v.io/x/ref/services/discovery/ble/ble" |
| ) |
| |
| func TestScannerWithUUID(t *testing.T) { |
| scanner := &scanner{ |
| uuid: "random-uuid", |
| } |
| |
| if scanner.matches("another-uuid", &ble.Service{}) { |
| t.Errorf("Unexpected match for another-uuid") |
| } |
| |
| if !scanner.matches("random-uuid", &ble.Service{}) { |
| t.Errorf("should have matched random-uuid") |
| } |
| } |
| |
| func TestScannerWithUUIDAndMap(t *testing.T) { |
| scanner := &scanner{ |
| uuid: "random-uuid", |
| attributes: map[string]string{ |
| "foo": "bar", |
| }, |
| } |
| |
| s := &ble.Service{ |
| Attributes: map[string]string{ |
| "foo": "bar", |
| }, |
| } |
| |
| if !scanner.matches("random-uuid", s) { |
| t.Errorf("should have matched service:%v", s) |
| } |
| |
| if scanner.matches("random-uuid2", s) { |
| t.Errorf("should not have matched service because of uuid") |
| } |
| |
| s.Attributes["key2"] = "value" |
| |
| if !scanner.matches("random-uuid", s) { |
| t.Errorf("should have matched service:%v", s) |
| } |
| |
| s.Attributes["foo"] ="wrong value" |
| if scanner.matches("random-uuid", s) { |
| t.Errorf("should not have matched service:%v", s) |
| } |
| } |