MCPcopy Index your code
hub / github.com/go-git/go-git / TestStatusCheckedInBeforeIgnored

Method TestStatusCheckedInBeforeIgnored

worktree_test.go:1077–1121  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

1075}
1076
1077func (s *WorktreeSuite) TestStatusCheckedInBeforeIgnored(c *C) {
1078 fs := memfs.New()
1079 storage := memory.NewStorage()
1080
1081 r, err := Init(storage, fs)
1082 c.Assert(err, IsNil)
1083
1084 w, err := r.Worktree()
1085 c.Assert(err, IsNil)
1086
1087 err = util.WriteFile(fs, "fileToIgnore", []byte("Initial data"), 0755)
1088 c.Assert(err, IsNil)
1089 _, err = w.Add("fileToIgnore")
1090 c.Assert(err, IsNil)
1091
1092 _, err = w.Commit("Added file that will be ignored later", defaultTestCommitOptions())
1093 c.Assert(err, IsNil)
1094
1095 err = util.WriteFile(fs, ".gitignore", []byte("fileToIgnore\nsecondIgnoredFile"), 0755)
1096 c.Assert(err, IsNil)
1097 _, err = w.Add(".gitignore")
1098 c.Assert(err, IsNil)
1099 _, err = w.Commit("Added .gitignore", defaultTestCommitOptions())
1100 c.Assert(err, IsNil)
1101 status, err := w.Status()
1102 c.Assert(err, IsNil)
1103 c.Assert(status.IsClean(), Equals, true)
1104 c.Assert(status, NotNil)
1105
1106 err = util.WriteFile(fs, "secondIgnoredFile", []byte("Should be completely ignored"), 0755)
1107 c.Assert(err, IsNil)
1108 status = nil
1109 status, err = w.Status()
1110 c.Assert(err, IsNil)
1111 c.Assert(status.IsClean(), Equals, true)
1112 c.Assert(status, NotNil)
1113
1114 err = util.WriteFile(fs, "fileToIgnore", []byte("Updated data"), 0755)
1115 c.Assert(err, IsNil)
1116 status = nil
1117 status, err = w.Status()
1118 c.Assert(err, IsNil)
1119 c.Assert(status.IsClean(), Equals, false)
1120 c.Assert(status, NotNil)
1121}
1122
1123func (s *WorktreeSuite) TestStatusEmptyDirty(c *C) {
1124 fs := memfs.New()

Callers

nothing calls this directly

Calls 8

NewStorageFunction · 0.92
InitFunction · 0.85
defaultTestCommitOptionsFunction · 0.85
WorktreeMethod · 0.80
CommitMethod · 0.65
AddMethod · 0.45
StatusMethod · 0.45
IsCleanMethod · 0.45

Tested by

no test coverage detected