Skip to content

Commit 503c8f6

Browse files
committed
Add NativeCmdStepTest to test serialization
1 parent 04d5f28 commit 503c8f6

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2021-2024 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.diffplug.spotless.generic;
17+
18+
import static org.assertj.core.api.Assumptions.assumeThat;
19+
20+
import java.io.File;
21+
import java.util.List;
22+
23+
import org.junit.jupiter.api.Test;
24+
25+
import com.diffplug.spotless.FormatterStep;
26+
import com.diffplug.spotless.ResourceHarness;
27+
import com.diffplug.spotless.StepHarnessWithFile;
28+
29+
public class NativeCmdStepTest extends ResourceHarness {
30+
31+
@Test
32+
public void testWithSed() {
33+
File sed = new File("/usr/bin/sed");
34+
assumeThat(sed).exists();
35+
FormatterStep step = NativeCmdStep.create("format-native", sed, List.of("s/placeholder/replaced/g"));
36+
StepHarnessWithFile.forStep(this, step)
37+
.testResource("native_cmd/dirty.txt", "native_cmd/clean.txt");
38+
}
39+
}

0 commit comments

Comments
 (0)