ref/discovery: Implement a ble plugin for discovery.
Change-Id: I45f7f0fda6e399e10f533d6ac72488365e7828f3
diff --git a/lib/discovery/plugins/ble/advertisement_test.go b/lib/discovery/plugins/ble/advertisement_test.go
new file mode 100644
index 0000000..5b4025c
--- /dev/null
+++ b/lib/discovery/plugins/ble/advertisement_test.go
@@ -0,0 +1,37 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ble
+
+import (
+ "github.com/pborman/uuid"
+ "reflect"
+ "testing"
+ vdiscovery "v.io/v23/discovery"
+ "v.io/x/ref/lib/discovery"
+)
+
+func TestConvertingBackAndForth(t *testing.T) {
+ v23Adv := discovery.Advertisement{
+ Service: vdiscovery.Service{
+ Addrs: []string{"localhost:1000", "example.com:540"},
+ InstanceUuid: []byte(uuid.NewUUID()),
+ Attrs: map[string]string{
+ "key1": "value1",
+ "key2": "value2",
+ },
+ },
+ ServiceUuid: uuid.NewUUID(),
+ }
+
+ adv := newAdvertisment(v23Adv)
+ out, err := adv.toDiscoveryAdvertisement()
+ if err != nil {
+ t.Errorf("unexpected error: %v", err)
+ }
+
+ if !reflect.DeepEqual(&v23Adv, out) {
+ t.Errorf("input does not equal output: %v, %v", v23Adv, out)
+ }
+}