Sergiusz Bazanski | 4c0e9b5 | 2020-04-08 22:42:33 +0200 | [diff] [blame] | 1 | package service |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | pb "code.hackerspace.pl/hscloud/devtools/depotview/proto" |
| 8 | ) |
| 9 | |
| 10 | func TestIntegration(t *testing.T) { |
| 11 | // TODO(q3k); bring up fake git |
| 12 | s := New("https://gerrit.hackerspace.pl/hscloud") |
| 13 | ctx := context.Background() |
| 14 | |
| 15 | res, err := s.Resolve(ctx, &pb.ResolveRequest{Ref: "master"}) |
| 16 | if err != nil { |
| 17 | t.Fatalf("Resolve(master): %v", err) |
| 18 | } |
| 19 | |
| 20 | if len(res.Hash) != 40 { |
| 21 | t.Fatalf("Resolve returned odd hash: %q", res.Hash) |
| 22 | } |
| 23 | |
| 24 | res2, err := s.Stat(ctx, &pb.StatRequest{Hash: res.Hash, Path: "//WORKSPACE"}) |
| 25 | if err != nil { |
| 26 | t.Fatalf("Stat(//WORKSPACE): %v", err) |
| 27 | } |
| 28 | |
| 29 | if want, got := pb.StatResponse_TYPE_FILE, res2.Type; want != got { |
| 30 | t.Fatalf("Stat(//WORKSPACE): got %v, want %v", got, want) |
| 31 | } |
| 32 | } |