(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestCollectionBlipHandler(t *testing.T) { |
| 21 | allDBContext := &DatabaseContext{} |
| 22 | allDBCollection := &DatabaseCollection{dbCtx: allDBContext} |
| 23 | allDBContext.CollectionByID = map[uint32]*DatabaseCollection{ |
| 24 | base.DefaultCollectionID: allDBCollection, |
| 25 | } |
| 26 | allDB := &Database{ |
| 27 | DatabaseContext: allDBContext, |
| 28 | } |
| 29 | realCollectionDB0 := &DatabaseCollection{dbCtx: &DatabaseContext{}} |
| 30 | realCollectionDB1 := &DatabaseCollection{dbCtx: &DatabaseContext{}} |
| 31 | testCases := []struct { |
| 32 | name string |
| 33 | blipMessage *blip.Message |
| 34 | err *base.HTTPError |
| 35 | collection *DatabaseCollectionWithUser |
| 36 | collectionContexts []*blipSyncCollectionContext |
| 37 | }{ |
| 38 | { |
| 39 | name: "NoCollections", |
| 40 | blipMessage: &blip.Message{}, |
| 41 | err: nil, |
| 42 | collection: &DatabaseCollectionWithUser{DatabaseCollection: allDBCollection}, |
| 43 | }, |
| 44 | { |
| 45 | name: "emptyCollectionNoAnInt", |
| 46 | blipMessage: &blip.Message{ |
| 47 | Properties: blip.Properties{ |
| 48 | BlipCollection: "a", |
| 49 | }, |
| 50 | }, |
| 51 | err: &base.HTTPError{Status: http.StatusBadRequest}, |
| 52 | collection: nil, |
| 53 | }, |
| 54 | { |
| 55 | name: "emptyCollectionMapping", |
| 56 | blipMessage: &blip.Message{ |
| 57 | Properties: blip.Properties{ |
| 58 | BlipCollection: "", |
| 59 | }, |
| 60 | }, |
| 61 | err: &base.HTTPError{Status: http.StatusBadRequest}, |
| 62 | collection: nil, |
| 63 | }, |
| 64 | { |
| 65 | name: "missingCollectionMapping", |
| 66 | blipMessage: &blip.Message{ |
| 67 | Properties: blip.Properties{ |
| 68 | BlipCollection: "1", |
| 69 | }, |
| 70 | }, |
| 71 | err: &base.HTTPError{Status: http.StatusBadRequest}, |
| 72 | collection: nil, |
| 73 | }, |
| 74 | { |
| 75 | name: "missingCollectionMapping", |
| 76 | blipMessage: &blip.Message{ |
| 77 | Properties: blip.Properties{ |
nothing calls this directly
no test coverage detected