Skip to content

Commit e62cf88

Browse files
authored
Update README and various errata (#537)
- Update build command in README and various spelling fixes - Add example to CONTRIBUTING page - Remove golint warnings - Clean up some error messages and comments
1 parent 85c73fc commit e62cf88

File tree

8 files changed

+27
-19
lines changed

8 files changed

+27
-19
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,19 @@ To run unit and integration tests:
5353
```
5454
go test -v ./...
5555
```
56-
If TOOLS_TESTING_UNIT is set to a true value in the environment, unit tests will run.
57-
If TOOLS_TESTING_INTEGRATION is set to a true value in the environment, integration tests will run.
56+
57+
If `TOOLS_TESTING_UNIT` is set to a true value in the shell environment, unit tests will run.
58+
59+
If `TOOLS_TESTING_INTEGRATION` is set to a true value in the shell environment, integration tests will run.
5860

5961
Integration tests require a `mongod` (running on port 33333) while unit tests do not.
6062

63+
Example of how to run a specific integration test:
64+
65+
```
66+
TOOLS_TESTING_INTEGRATION=true go test -v ./... -run TestImportDocuments
67+
```
68+
6169
To run the quality assurance tests, you need to have the latest stable version of the rebuilt tools, `mongod`, `mongos`, and `mongo` in your current working directory.
6270

6371
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cd mongo-tools
2626

2727
Then run `./make build` to build all the tools, placing them in the `bin` directory inside the repository.
2828

29-
You can also build a subset of the tools using the `-tools` option. For example, `./make build -tools=mongodump,mongorestore` builds only `mongodump` and `mongorestore`.
29+
You can also build a subset of the tools using the `-pkgs` option. For example, `./make build -pkgs=mongodump,mongorestore` builds only `mongodump` and `mongorestore`.
3030

3131
To use the build/test scripts in this repository, you **_must_** set GOROOT to your Go root directory. This may depend on how you installed Go.
3232

common/db/optime.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (ot OpTime) String() string {
8888
return fmt.Sprintf("{Timestamp: %v, Term: %v, Hash: %v}", ot.Timestamp, nil, *ot.Hash)
8989
} else if ot.Term != nil && ot.Hash == nil {
9090
return fmt.Sprintf("{Timestamp: %v, Term: %v, Hash: %v}", ot.Timestamp, *ot.Term, nil)
91-
} else {
92-
return fmt.Sprintf("{Timestamp: %v, Term: %v, Hash: %v}", ot.Timestamp, nil, nil)
9391
}
92+
93+
return fmt.Sprintf("{Timestamp: %v, Term: %v, Hash: %v}", ot.Timestamp, nil, nil)
9494
}

common/idx/index_catalog.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ func (i *IndexCatalog) DeleteIndexes(database, collection string, dropCmd bson.D
225225
i.addIndex(database, collection, idIndexName, idIndex)
226226
}
227227
return nil
228-
} else {
229-
// Drop an index by name.
230-
delete(collIndexes, indexToDrop)
231-
return nil
232228
}
229+
230+
// Drop an index by name.
231+
delete(collIndexes, indexToDrop)
232+
return nil
233233
case bson.D:
234234
var toDelete []string
235235
// Drop an index by key pattern.

mongofiles/mongofiles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (mf *MongoFiles) ValidateCommand(args []string) error {
170170
}
171171

172172
if mf.StorageOptions.GridFSPrefix == "" {
173-
return fmt.Errorf("--prefix can not be blank")
173+
return fmt.Errorf("--prefix cannot be blank")
174174
}
175175

176176
mf.Command = args[0]

mongoimport/mongoimport.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (imp *MongoImport) validateSettings(args []string) error {
161161
}
162162
if imp.InputOptions.FieldFile != nil &&
163163
*imp.InputOptions.FieldFile == "" {
164-
return fmt.Errorf("--fieldFile can not be empty string")
164+
return fmt.Errorf("--fieldFile cannot be empty string")
165165
}
166166
if imp.InputOptions.Fields != nil &&
167167
imp.InputOptions.FieldFile != nil {
@@ -185,19 +185,19 @@ func (imp *MongoImport) validateSettings(args []string) error {
185185
} else {
186186
// input type is JSON
187187
if imp.InputOptions.HeaderLine {
188-
return fmt.Errorf("can not use --headerline when input type is JSON")
188+
return fmt.Errorf("cannot use --headerline when input type is JSON")
189189
}
190190
if imp.InputOptions.Fields != nil {
191-
return fmt.Errorf("can not use --fields when input type is JSON")
191+
return fmt.Errorf("cannot use --fields when input type is JSON")
192192
}
193193
if imp.InputOptions.FieldFile != nil {
194-
return fmt.Errorf("can not use --fieldFile when input type is JSON")
194+
return fmt.Errorf("cannot use --fieldFile when input type is JSON")
195195
}
196196
if imp.IngestOptions.IgnoreBlanks {
197-
return fmt.Errorf("can not use --ignoreBlanks when input type is JSON")
197+
return fmt.Errorf("cannot use --ignoreBlanks when input type is JSON")
198198
}
199199
if imp.InputOptions.ColumnsHaveTypes {
200-
return fmt.Errorf("can not use --columnsHaveTypes when input type is JSON")
200+
return fmt.Errorf("cannot use --columnsHaveTypes when input type is JSON")
201201
}
202202
}
203203

@@ -211,7 +211,7 @@ func (imp *MongoImport) validateSettings(args []string) error {
211211
if imp.IngestOptions.Mode == "" {
212212
imp.IngestOptions.Mode = modeUpsert
213213
} else if imp.IngestOptions.Mode == modeInsert {
214-
return fmt.Errorf("can not use --upsertFields with --mode=insert")
214+
return fmt.Errorf("cannot use --upsertFields with --mode=insert")
215215
}
216216
imp.upsertFields = strings.Split(imp.IngestOptions.UpsertFields, ",")
217217
if err := validateFields(imp.upsertFields, imp.InputOptions.UseArrayIndexFields); err != nil {

mongoimport/typed_fields.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func ColumnNames(fs []ColumnSpec) (s []string) {
9090
}
9191

9292
// ParseTypedHeader produces a ColumnSpec from a header item, extracting type
93-
// information from the it. The parseGrace is passed along to the new ColumnSpec.
93+
// information from it. The parseGrace is passed along to the new ColumnSpec.
9494
func ParseTypedHeader(header string, parseGrace ParseGrace) (f ColumnSpec, err error) {
9595
match := columnTypeRE.FindStringSubmatch(header)
9696
if len(match) != 4 {

mongoimport/typed_fields_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func init() {
2727
func TestTypedHeaderParser(t *testing.T) {
2828
testtype.SkipUnlessTestType(t, testtype.UnitTestType)
2929

30-
Convey("Using 'zip.string(),number.double(),foo.auto()'", t, func() {
30+
Convey("Using 'zip.string(),number.double(),foo.auto(),bar.date(January 2, (2006))'", t, func() {
3131
var headers = []string{"zip.string()", "number.double()", "foo.auto()", `bar.date(January 2\, \(2006\))`}
3232
var colSpecs []ColumnSpec
3333
var err error

0 commit comments

Comments
 (0)