blob: 7e6ae2d5a2dd658af2fe58ba8e7e5bddddef5937 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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())
}
}
|