aboutsummaryrefslogtreecommitdiffstats
path: root/octopart_test.go
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-09-20 15:36:30 +0200
committerbnewbold <bnewbold@robocracy.org>2012-09-20 15:36:30 +0200
commitb0ecc94ef69d489dcc775038a0c6f65c1c960c8e (patch)
tree48b0873c3fa211cbbb9bbf0c0ec22f140c08ad43 /octopart_test.go
parentc3591d04490d10b7a05e1aefff903430fecc2ba8 (diff)
downloadbommom-b0ecc94ef69d489dcc775038a0c6f65c1c960c8e.tar.gz
bommom-b0ecc94ef69d489dcc775038a0c6f65c1c960c8e.zip
WIP
Diffstat (limited to 'octopart_test.go')
-rw-r--r--octopart_test.go87
1 files changed, 49 insertions, 38 deletions
diff --git a/octopart_test.go b/octopart_test.go
index fdbd9b0..d2c8fbd 100644
--- a/octopart_test.go
+++ b/octopart_test.go
@@ -1,52 +1,63 @@
package main
import (
+ "log"
+ "os"
"testing"
- "log"
)
func TestApiCall(t *testing.T) {
- oc := NewOctopartClient("")
- result, err := oc.apiCall("parts/search", map[string]string{"q": "ne555", "limit": "2"})
- if err != nil {
- t.Errorf("Error with api call: " + err.Error())
- }
- log.Println(result["hits"])
+ oc := NewOctopartClient("")
+ result, err := oc.apiCall("parts/search", map[string]string{"q": "ne555", "limit": "2"})
+ if err != nil {
+ t.Errorf("Error with api call: " + err.Error())
+ }
+ log.Println(result["hits"])
}
-func TestGetMarketInfo(t *testing.T) {
- oc := NewOctopartClient("")
- log.Println("Running the first time...")
- result, err := oc.GetMarketInfo([]string{"ti", "atmel", "atmel"}, []string{"ne555", "attiny*", "avrtiny123qqq?"})
- if err != nil {
- t.Errorf("Error with api call: " + err.Error())
- }
- for i, r := range result {
- if r == nil {
- log.Printf("\t%d: %s", i, "nil")
- } else {
- log.Printf("\t%d: %s", i, r.(map[string]interface{})["detail_url"])
- }
- }
- log.Println("Running a second time, results should be cached...")
- result, err = oc.GetMarketInfo([]string{"ti", "atmel", "atmel"}, []string{"ne555", "attiny*", "avrtiny123qqq?"})
- if err != nil {
- t.Errorf("Error with api call: " + err.Error())
- }
- for i, r := range result {
- if r == nil {
- log.Printf("\t%d: %s", i, "nil")
- } else {
- log.Printf("\t%d: %s", i, r.(map[string]interface{})["detail_url"])
- }
+func TestGetMarketInfoList(t *testing.T) {
+ oc := NewOctopartClient("")
+ log.Println("Running the first time...")
+ result, err := oc.GetMarketInfoList([]string{"ti", "atmel", "atmel"}, []string{"ne555", "attiny*", "avrtiny123qqq?"})
+ if err != nil {
+ t.Errorf("Error with api call: " + err.Error())
+ }
+ for i, r := range result {
+ if r == nil {
+ log.Printf("\t%d: %s", i, "nil")
+ } else {
+ log.Printf("\t%d: %s", i, r.(map[string]interface{})["detail_url"])
+ }
+ }
+ log.Println("Running a second time, results should be cached...")
+ result, err = oc.GetMarketInfoList([]string{"ti", "atmel", "atmel"}, []string{"ne555", "attiny*", "avrtiny123qqq?"})
+ if err != nil {
+ t.Errorf("Error with api call: " + err.Error())
+ }
+ for i, r := range result {
+ if r == nil {
+ log.Printf("\t%d: %s", i, "nil")
+ } else {
+ log.Printf("\t%d: %s", i, r.(map[string]interface{})["detail_url"])
+ }
+ }
+ log.Println("Running in single mode, result should be cached...")
+ result_single, err := oc.GetMarketInfo("ti", "ne555")
+ if err != nil {
+ t.Errorf("Error with api call: " + err.Error())
+ }
+ if result_single == nil {
+ log.Printf("\t%d: %s", "nil")
+ } else {
+ log.Printf("\t%d: %s", result_single["detail_url"])
}
}
func TestAttachInfo(t *testing.T) {
- _, b := makeTestBom()
- bm := &BomMeta{}
- oc := NewOctopartClient("")
- oc.AttachMarketInfo(oc)
- DumpBomAsText(bm, b, os.Stdout)
+ _, b := makeTestBom()
+ bm := &BomMeta{}
+ oc := NewOctopartClient("")
+ oc.AttachMarketInfoBom(b)
+ t.Errorf("unimplemented")
+ DumpBomAsText(bm, b, os.Stdout)
}
-