| 82 | } |
| 83 | |
| 84 | func Test_ParseTree(t *testing.T) { |
| 85 | const inputSha = SHA("1efecd717188441397c07f267cf468fdf04d4796") |
| 86 | expected := Tree{ |
| 87 | _type: "tree", |
| 88 | size: "156", |
| 89 | Blobs: []objectMeta{ |
| 90 | objectMeta{SHA("af6e4fe91a8f9a0f3c03cbec9e1d2aac47345d67"), "100644", ".gitignore"}, |
| 91 | objectMeta{SHA("f45d37d9add8f21eb84678f6d2c66377c4dd0c5e"), "100644", "cat-file.go"}, |
| 92 | objectMeta{SHA("2c225b962d6666011c69ca5c2c67204959f8ba32"), "100644", "cat-file_test.go"}, |
| 93 | }, |
| 94 | Trees: []objectMeta{ |
| 95 | objectMeta{SHA("d564d0bc3dd917926892c55e3706cc116d5b165e"), "040000", "examples"}, |
| 96 | }, |
| 97 | } |
| 98 | result, err := NewObject(inputSha) |
| 99 | if err != nil { |
| 100 | t.Error(err) |
| 101 | } |
| 102 | if !reflect.DeepEqual(expected, result) { |
| 103 | t.Errorf("Expected and result don't match:\n\n%+v\n\n%+v", expected, result) |
| 104 | } |
| 105 | |
| 106 | } |
| 107 | |
| 108 | func Test_ParseBlob(t *testing.T) { |
| 109 | const inputSha = SHA("af6e4fe91a8f9a0f3c03cbec9e1d2aac47345d67") |