MCPcopy Create free account
hub / github.com/go-git/go-git / TestStatusCheckedInBeforeIgnored

Method TestStatusCheckedInBeforeIgnored

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

Source from the content-addressed store, hash-verified

988}
989
990func (s *WorktreeSuite) TestStatusCheckedInBeforeIgnored(c *C) {
991 fs := memfs.New()
992 storage := memory.NewStorage()
993
994 r, err := Init(storage, fs)
995 c.Assert(err, IsNil)
996
997 w, err := r.Worktree()
998 c.Assert(err, IsNil)
999
1000 err = util.WriteFile(fs, "fileToIgnore", []byte("Initial data"), 0755)
1001 c.Assert(err, IsNil)
1002 _, err = w.Add("fileToIgnore")
1003 c.Assert(err, IsNil)
1004
1005 _, err = w.Commit("Added file that will be ignored later", defaultTestCommitOptions)
1006 c.Assert(err, IsNil)
1007
1008 err = util.WriteFile(fs, ".gitignore", []byte("fileToIgnore\nsecondIgnoredFile"), 0755)
1009 c.Assert(err, IsNil)
1010 _, err = w.Add(".gitignore")
1011 c.Assert(err, IsNil)
1012 _, err = w.Commit("Added .gitignore", defaultTestCommitOptions)
1013 c.Assert(err, IsNil)
1014 status, err := w.Status()
1015 c.Assert(err, IsNil)
1016 c.Assert(status.IsClean(), Equals, true)
1017 c.Assert(status, NotNil)
1018
1019 err = util.WriteFile(fs, "secondIgnoredFile", []byte("Should be completely ignored"), 0755)
1020 c.Assert(err, IsNil)
1021 status = nil
1022 status, err = w.Status()
1023 c.Assert(err, IsNil)
1024 c.Assert(status.IsClean(), Equals, true)
1025 c.Assert(status, NotNil)
1026
1027 err = util.WriteFile(fs, "fileToIgnore", []byte("Updated data"), 0755)
1028 c.Assert(err, IsNil)
1029 status = nil
1030 status, err = w.Status()
1031 c.Assert(err, IsNil)
1032 c.Assert(status.IsClean(), Equals, false)
1033 c.Assert(status, NotNil)
1034}
1035
1036func (s *WorktreeSuite) TestStatusEmptyDirty(c *C) {
1037 fs := memfs.New()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected