Bladeren bron

Exposed some values in Field objects

arianagiroux 3 weken geleden
bovenliggende
commit
622926cd13
4 gewijzigde bestanden met toevoegingen van 22 en 22 verwijderingen
  1. 7 7
      bug.go
  2. 4 4
      bug_test.go
  3. 5 5
      io.go
  4. 6 6
      io_test.go

+ 7 - 7
bug.go

@@ -11,16 +11,16 @@ type Bug struct {
 	Title        string        // The title of the bug in human readable format
 	Description  Field         // The description of the bug
 	Status       Field         // The status of the bug
-	Tags         VariadicField // A slice of [buggo.Tag] structs
-	Blockedby    VariadicField // A slice of [buggo.Blocker] structs
+	Tags         VariadicField // A slice of VariadicFields
+	Blockedby    VariadicField // A slice of VariadicFields
 	Path         string        // The path to the bug
 	machineTitle string        // The machine parseable bug title
 }
 
 // A struct representing data that is tied to data on disk
 type Field struct {
-	path string
-	data string
+	Path string
+	Data string
 }
 
 // VariadicFields hold lists of Field objects.
@@ -47,17 +47,17 @@ func (b Bug) View() string {
 
 	var tags string
 	for _, tag := range b.Tags.Fields {
-		tags = tags + string(tag.data) + ", "
+		tags = tags + string(tag.Data) + ", "
 	}
 
 	var blockers string
 	for _, blocker := range b.Blockedby.Fields {
-		blockers = blockers + string(blocker.data) + ", "
+		blockers = blockers + string(blocker.Data) + ", "
 	}
 
 	return fmt.Sprintf("%s\n\n%s\n---\nTags:\t%s\nBlockedby:\t%s\n---\n%s",
 		headerStyle.Render(b.Title),
-		subtitleStyle.Render("status:\t"+b.Status.data),
+		subtitleStyle.Render("status:\t"+b.Status.Data),
 		tagsStyle.Render(tags),
 		tagsStyle.Render(blockers),
 		b.Description,

+ 4 - 4
bug_test.go

@@ -16,15 +16,15 @@ func TestVariadicField(t *testing.T) {
 func TestView(t *testing.T) {
 	bug := Bug{
 		Title:       "title",
-		Description: Field{data: "description"},
-		Status:      Field{data: "statustest"},
+		Description: Field{Data: "description"},
+		Status:      Field{Data: "statustest"},
 		Tags: VariadicField{
 			Fields: []Field{
-				{data: "tag1"}, {data: "tag2"},
+				{Data: "tag1"}, {Data: "tag2"},
 			}},
 		Blockedby: VariadicField{
 			Fields: []Field{
-				{data: "blocker1"}, {data: "blocker2"},
+				{Data: "blocker1"}, {Data: "blocker2"},
 			}},
 	}
 

+ 5 - 5
io.go

@@ -31,7 +31,7 @@ func loadVariadicField(pathOnDisk string, vf VariadicField) (v VariadicField, er
 		if err != nil {
 			return vf, err
 		}
-		vf.Fields = append(vf.Fields, Field{data: data, path: file.Name()})
+		vf.Fields = append(vf.Fields, Field{Data: data, Path: file.Name()})
 	}
 
 	return vf, err
@@ -40,17 +40,17 @@ func loadVariadicField(pathOnDisk string, vf VariadicField) (v VariadicField, er
 // Loads a bug from disk
 func LoadBug(path string) (bug Bug, err error) {
 	// Required Fields
-	description := &Field{path: "/description"}
-	status := &Field{path: "/status"}
+	description := &Field{Path: "/description"}
+	status := &Field{Path: "/status"}
 	requiredFields := []*Field{description, status}
 
 	for _, field := range requiredFields {
-		data, err := readPath(path + field.path)
+		data, err := readPath(path + field.Path)
 		if err != nil {
 			return Bug{}, err
 		}
 
-		field.data = data
+		field.Data = data
 	}
 
 	// Variadic Fields

+ 6 - 6
io_test.go

@@ -34,18 +34,18 @@ func TestLoadBugSuccess(t *testing.T) {
 	}
 
 	testBug := Bug{
-		Description: Field{data: "test description\n", path: "/description"},
-		Status:      Field{data: "open:test\n", path: "/status"},
+		Description: Field{Data: "test description\n", Path: "/description"},
+		Status:      Field{Data: "open:test\n", Path: "/status"},
 		Tags: VariadicField{
 			Path: "/tags", Fields: []Field{
-				{data: "tag-1", path: "tag-1"},
-				{data: "tag-2", path: "tag-2"},
+				{Data: "tag-1", Path: "tag-1"},
+				{Data: "tag-2", Path: "tag-2"},
 			},
 		},
 		Blockedby: VariadicField{
 			Path: "/blockedby", Fields: []Field{
-				{data: "blocker-1", path: "blocker-1"},
-				{data: "blocker-2", path: "blocker-1"},
+				{Data: "blocker-1", Path: "blocker-1"},
+				{Data: "blocker-2", Path: "blocker-1"},
 			},
 		},
 	}