diff options
author | bnewbold <bnewbold@robocracy.org> | 2012-04-10 20:58:13 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2012-04-11 10:58:08 -0400 |
commit | 78b207a40436d0c15a2b806171914d802cd20661 (patch) | |
tree | 730d02b32e5d54b2512a319d7ced34ad8ce3aacf /core_test.go | |
parent | 3c7a4451e62d27bbe9dc8eb2c16e2ff5607d1b04 (diff) | |
download | bommom-78b207a40436d0c15a2b806171914d802cd20661.tar.gz bommom-78b207a40436d0c15a2b806171914d802cd20661.zip |
tests passing
Diffstat (limited to 'core_test.go')
-rw-r--r-- | core_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/core_test.go b/core_test.go new file mode 100644 index 0000000..7e6ae2d --- /dev/null +++ b/core_test.go @@ -0,0 +1,41 @@ +package main + +import ( + "encoding/json" + //"fmt" + "os" + "testing" +) + +func makeTestBom() *Bom { + op1 := OfferPrice{Currency: "usd", Price: 1.0, MinQty: 1} + op2 := OfferPrice{Currency: "usd", Price: 0.8, MinQty: 100} + o := Offer{Sku: "A123", Distributor: "Acme", Prices: []OfferPrice{op1, op2}} + //o.AddOfferPrice(op1) + //o.AddOfferPrice(op2) + li := LineItem{Mfg: "WidgetCo", + Mpn: "WIDG0001", + Elements: []string{"W1", "W2"}, + Offers: []Offer{o}} + //li.AddOffer(o) + b := NewBom("test01") + b.AddLineItem(&li) + return b +} + +func TestNewBom(t *testing.T) { + b := makeTestBom() + if b == nil { + t.Errorf("Something went wrong") + } +} + +func TestBomJSONDump(t *testing.T) { + + b := makeTestBom() + enc := json.NewEncoder(os.Stdout) + + if err := enc.Encode(b); err != nil { + t.Errorf("Error encoding: " + err.Error()) + } +} |