Esempio n. 1
0
func getDB() *bolt.DB {
	pth := os.Getenv("QUIMBY_DB")
	if pth == "" {
		log.Fatal("you must specify a db location with QUIMBY_DB")
	}
	db, err := quimby.GetDB(pth)
	if err != nil {
		log.Fatalf("could not open db at %s - %v", pth, err)
	}
	return db
}
Esempio n. 2
0
func getDB(b *bootstrap) *bolt.DB {
	fmt.Printf("data directory path: ")
	fmt.Scanf("%s\n", &b.Home)

	if err := os.MkdirAll(b.Home, 0777); err != nil {
		log.Fatal(err)
	}

	b.DBPath = filepath.Join(b.Home, "quimby.db")
	db, err := quimby.GetDB(b.DBPath)
	if err != nil {
		log.Fatalf("could not open db at %s - %v", b.DBPath, err)
	}
	return db
}
Esempio n. 3
0
				} else if r.URL.Path == "/clients" {
					var m map[string]string
					dec := json.NewDecoder(r.Body)
					err := dec.Decode(&m)
					Expect(err).To(BeNil())
					clients = append(clients, m)
				}
			}
		}))

		var err error
		dir, err = ioutil.TempDir("", "")
		pth = path.Join(dir, "db")
		Expect(err).To(BeNil())

		db, err = quimby.GetDB(pth)
		Expect(err).To(BeNil())

		g = &quimby.Gadget{
			Name: "lights",
			Host: ts.URL,
			DB:   db,
		}
		err = g.Save()
		Expect(err).To(BeNil())
	})

	AfterEach(func() {
		db.Close()
		os.RemoveAll(dir)
		ts.Close()