@@ -28,17 +28,27 @@ public void TestCleanup()
28
28
Directory . SetCurrentDirectory ( TestContext . DeploymentDirectory ! ) ;
29
29
}
30
30
31
- [ TestMethod ]
32
- public async Task TestGitFails ( )
31
+ void Commit ( string commitMessage )
32
+ {
33
+ Cmd . Call ( "git" , "add ." ) ;
34
+ Cmd . Call ( "git" , $ "commit -m \" { commitMessage } \" ") ;
35
+ }
36
+
37
+ void CreateProject ( string initialBranch )
33
38
{
34
- string branch = "main" ;
35
- Cmd . Call ( "git" , $ "init --initial-branch={ branch } ") ;
39
+ Cmd . Call ( "git" , $ "init --initial-branch={ initialBranch } ") ;
36
40
Cmd . Call ( "git" , "config user.name user" ) ;
37
41
Cmd . Call ( "git" , "config user.email user@example.com" ) ;
38
- Cmd . Call ( "git" , "add ." ) ;
39
- string message = "Initial Commit" ;
40
- Cmd . Call ( "git" , $ "commit -m { message } ") ;
42
+ Commit ( "Initial Commit" ) ;
41
43
Cmd . Call ( "git" , "checkout -b otherbranch" ) ;
44
+ }
45
+
46
+ [ TestMethod ]
47
+ [ DeploymentItem ( "Template.tt" ) ]
48
+ [ DeploymentItem ( "ReleaseNote.config.toml" ) ]
49
+ public async Task TestGitFails ( )
50
+ {
51
+ CreateProject ( initialBranch : "main" ) ;
42
52
43
53
TestConsole c = new TestConsole ( ) ;
44
54
AnsiConsole . Console = c ;
@@ -48,5 +58,60 @@ public async Task TestGitFails()
48
58
Assert . IsTrue ( c . Output . Contains ( "git produced output while failing" ) ) ;
49
59
Assert . IsTrue ( c . Output . Contains ( "hblaugh" ) ) ;
50
60
}
61
+
62
+ [ TestMethod ]
63
+ [ DeploymentItem ( "Template.tt" ) ]
64
+ [ DeploymentItem ( "ReleaseNote.config.toml" ) ]
65
+ public async Task TestNoChangesMade ( )
66
+ {
67
+ CreateProject ( initialBranch : "main" ) ;
68
+
69
+ TestConsole c = new TestConsole ( ) ;
70
+ AnsiConsole . Console = c ;
71
+ string [ ] args = [ "check" , "--compare-with" , "main" ] ;
72
+ int result = await Program . Main ( args ) ;
73
+ Assert . AreEqual ( 0 , result ) ;
74
+ Assert . AreEqual ( "On main branch, or no diffs, so no newsfragment required.\n " , c . Output ) ;
75
+ }
76
+
77
+ [ TestMethod ]
78
+ [ DeploymentItem ( "Template.tt" ) ]
79
+ [ DeploymentItem ( "ReleaseNote.config.toml" ) ]
80
+ public async Task TestNoChangesMadeConfigPath ( )
81
+ {
82
+ File . Move ( "ReleaseNote.config.toml" , "not-pyproject.toml" ) ;
83
+ CreateProject ( initialBranch : "main" ) ;
84
+
85
+ TestConsole c = new TestConsole ( ) ;
86
+ AnsiConsole . Console = c ;
87
+ string [ ] args = [ "check" , "--compare-with" , "main" , "--config" , "not-pyproject.toml" ] ;
88
+ int result = await Program . Main ( args ) ;
89
+ Assert . AreEqual ( 0 , result ) ;
90
+ Assert . AreEqual ( "On main branch, or no diffs, so no newsfragment required.\n " , c . Output ) ;
91
+ }
92
+
93
+ [ TestMethod ]
94
+ [ DeploymentItem ( "Template.tt" ) ]
95
+ [ DeploymentItem ( "ReleaseNote.config.toml" ) ]
96
+ public async Task TestFragmentExists ( )
97
+ {
98
+ CreateProject ( initialBranch : "main" ) ;
99
+
100
+ File . WriteAllText ( "helloworld.txt" , "hello world" ) ;
101
+ Commit ( "add a file" ) ;
102
+
103
+ Directory . CreateDirectory ( "ChangeLog.d" ) ;
104
+ string fpath = Path . GetFullPath ( "ChangeLog.d/1234.feature" ) ;
105
+ File . WriteAllText ( fpath , "Adds gravity back" ) ;
106
+ Commit ( "add a newsfragment" ) ;
107
+
108
+ TestConsole c = new TestConsole ( ) ;
109
+ AnsiConsole . Console = c ;
110
+ AnsiConsole . Profile . Width = 255 ;
111
+ string [ ] args = [ "check" , "--compare-with" , "main" ] ;
112
+ int result = await Program . Main ( args ) ;
113
+ Assert . AreEqual ( 0 , result ) ;
114
+ Assert . IsTrue ( c . Output . EndsWith ( $ "Found:\n 1. { fpath } \n ") ) ;
115
+ }
51
116
}
52
117
}
0 commit comments